Releases: moleculerjs/moleculer
v0.14.35
What's Changed
- chore(peer-deps): allow to work with pino v9 by @jellydn in #1282
- Runner: log runner error through util.inspect by @PetrChalov in #1304
- fix: Update default type for ServiceSchema generic to Service. by @marceliwac in #1299
- fix: updated removePendingRequestByNodeID by @JS-AK in #1306
New Contributors
- @jellydn made their first contribution in #1282
- @PetrChalov made their first contribution in #1304
- @JS-AK made their first contribution in #1306
Full Changelog: v0.14.34...v0.14.35
v0.14.34
What's Changed
- feat: Expand the type for ServiceSchema to allow for typed lifecycle handlers by @marceliwac in #1272
- Fix runner use of moleculer.config function with default export by @shawnmcknight in #1284
- Improve broker error handler types by @shawnmcknight in #1286
- Don't plugging third-party Promise library for ioredis in RedisTransporter by @kuzalekon in #1290
- fixed numeric cache key issue by @icebob #1289
New Contributors
- @marceliwac made their first contribution in #1272
- @kuzalekon made their first contribution in #1290
Full Changelog: v0.14.33...v0.14.34
v0.15.0-beta1
Migration guide from 0.14 to 0.15
Breaking changes
Minimum Node 18
The minimum supported Node version is changed from Node 10 to Node 18.
Communication protocol has been changed
The Moleculer communication protocol has been changed. The new protocol version is 5
. However all schema-based serializer has been removed from the core repo. It means v0.15 Moleculer nodes will able to communicate with v0.14 nodes, if you disable version checking in broker options.
Schema-based serializers (ProtoBuf, Avro, Thrift) are removed
The reason is desribed in this issue: #882
If you use one of those, you should change it to one of these schemaless serializers: MsgPack, Notepack.io, JSON, JSONExt, CBOR
EventLegacy tracing export is removed
The EventLegacy
tracing exporter is removed. Use the Event
tracing exporter instead.
Legacy event handler is removed
The legacy event handler signature (user.created(payload, sender, eventName)
) is removed. You should use the new Context
based signature which was introduced in version 0.14.
Legacy event handler
module.exports = {
name: "accounts",
events: {
"user.created"(payload, sender, eventName) {
// ...
}
}
};
Supported event handler
module.exports = {
name: "accounts",
events: {
"user.created"(ctx) {
console.log("Payload:", ctx.params);
console.log("Sender:", ctx.nodeID);
console.log("We have also metadata:", ctx.meta);
console.log("The called event name:", ctx.eventName);
// ...
}
}
};
New REPL options
In order to the REPL options can be more extensible, a new replOptions
broker option is introduces. You can use it instead of the old replCommands
and replDelimiter
broker options.
Old REPL options
// moleculer.config.js
module.exports = {
replDelimiter: "mol # ",
replCommands: [
{
command: "hello <name>",
action(broker, args) {
// ...
}
}
]
}
New REPL options
// moleculer.config.js
module.exports = {
replOptions: {
delimiter: "mol # ",
customCommands: [
{
command: "hello <name>",
action(broker, args) {
// ...
}
}
]
}
}
Please note, you should rename the
replCommands
property tocustomCommands
, as well.
Action streaming
The built-in Stream
sending has been rewritten. Now it accepts params
besides the Stream
instance.
The Stream
parameter moved from ctx.params
into calling options under a stream
property.
New way to send a stream with extra parameters
The stream instance is passed as a calling options, so you can use ctx.params
as a normal action call.
ctx.call("file.save", { filename: "as.txt" }, { stream: fs.createReadStream() });
New way to receive a stream
// file.service.js
module.exports = {
name: "file",
actions: {
save(ctx) {
// The stream is in Context directly
const stream = ctx.stream;
const s = fs.createWriteStream(ctx.params.filename);
stream.pipe(s);
}
}
};
Removed deprecated functions and signatures
Removed deprecated broker.createService
signature
The broker.createService
second argument (for service schema extending) is removed. You should use the mixins
in service schema.
Removed deprecated event sending method signature
In previous versions, the emit
, broadcast
and broadcastLocal
methods accept a group String
or groups as Array<String>
as third arguments, instead of an opts
.
This signature is removed, you should always pass an opts
object as 3rd argument.
Removed deprecated middleware as a Function
We removed and old and deprecated middleware signature where the middleware was localAction
function. Now ServiceBroker
accepts middleware as Object
only.
Removed deprecated getLocalService
signature.
The broker.getLocalService
supports only getLocalService(name|obj)
without second version
parameter. If you want to get a versioned service, use the v1.posts
argument or as object { name: "posts", version: 1}
Removed Service
constructor 3rd argument.
The Service
constructor had a 3rd argument as schemaMods
which was deprecated because you should use mixins
instead modifier schemas.
Garbage collector and event-loop metrics removed
Since gc-stats
and event-loop-stats
native libraries are not maintained and they are not compatible with newer Node versions, they are removed from the built-in metrics.
Removed metrics:
process.gc.time
process.gc.total.time
process.gc.executed.total
process.eventloop.lag.min
process.eventloop.lag.avg
process.eventloop.lag.max
process.eventloop.lag.count
process.internal.active.requests
Removed STAN (NATS Streaming) transporter
The STAN (NATS Streaming) transporter has been removed while it's deprecated and not supported by the NATS.io, as well. More info: https://nats-io.gitbook.io/legacy-nats-docs/nats-streaming-server-aka-stan
Rewritten Kafka transporter (based on kafkajs)
The previous kafka-node
based transporter has been rewritten to a kafkajs
based transporter. It means, you should migrate your Kafka Transporter options.
// moleculer.config.js
module.exports = {
transporter: {
type: "Kafka",
options: {
// KafkaClient options. More info: https://kafka.js.org/docs/configuration
client: {
brokers: [/*...*/]
},
// KafkaProducer options. More info: https://kafka.js.org/docs/producing#options
producer: {},
// ConsumerGroup options. More info: https://kafka.js.org/docs/consuming#a-name-options-a-options
consumer: {},
// Advanced options for `send`. More info: https://kafka.js.org/docs/producing#producing-messages
publish: {},
// Advanced message options for `send`. More info: https://kafka.js.org/docs/producing#message-structure
publishMessage: {
partition: 0
}
}
}
}
About new configuration options, check this documentation: https://kafka.js.org/docs/configuration
Removed legacy NATS library ([email protected]) implementation
The legacy [email protected]
transporter implementation is removed. This version supports only [email protected]
library.
The Fastest Validator options changed.
In 0.15 the useNewCustomCheckFunction
default value is changed from false
to true
. It means, if you have old custom checker function in your parameter validation schemas, you should rewrite it to the new custom check function form.
You can see example about migration here: https://github.com/icebob/fastest-validator/blob/master/CHANGELOG.md#new-custom-function-signature
Rewritten Typescript definition files
The previously used huge one-file index.d.ts
file has been rewritten and separated to multiple d.ts
files, all are placed besides the source file. It may causes breaking changes in Typescript projects.
Other breaking changes
ServiceBroker.Promise
is removed. Usebroker.Promise
orthis.Promise
inside aService
.
New features
New JSON Extended serializer
We implemented a new JSON serializer which unlike the native JSON serializer, it supports serializing Buffer
, BigInt
, Date
, Map
, Set
and RegExp
classes, as well.
Example
// moleculer.config.js
module.exports = {
serializer: "JSONExt"
}
Custom extensions
You can extend the serializer with custom types.
Example to extend with a custom class serializing/deserializing
// MyClass.js
class MyClass {
constructor(a, b) {
this.a = a;
this.b = b;
}
}
// moleculer.config.js
module.exports = {
serializer: {
type: "JSONExt",
options: {
customs: [
{
// This is the identifier of the custom type
prefix: "AB",
// This function checks the type of JSON value
check: v => v instanceof MyClass,
// Serialize the custom class properties to a String
serialize: v => v.a + "|" + v.b,
// Deserialize the JSON string to custom class instance and set properties
deserialize: v => {
const [a, b] = v.split("|");
return new MyClass(parseInt(a), b);
}
}
]
}
}
}
New Request headers
We added a new headers
property in calling options and Context class to store meta information for an action calling or an event emitting.
The difference between headers
and meta
is that the meta
is always passed to all action calls in a chain and merged, the headers
is transferred only to the actual action call and not passed to the nested calls.
Please note, header keys start with
$
means internal header keys (e.g.$streamObjectMode
). We recommend to don't use this prefix for your keys to avoid conflicts.
Set headers in action calls
broker.call("posts.list", { limit: 100 }, {
headers: {
customProp: "customValue"
...
v0.14.33
What's Changed
- autodetect Redis type discoverer when using redis SSL URI by @Freezystem in #1260
- Transit improve by @0x0a0d in #1258
- change from 'connect' to 'ready' event in redis clients. Fixes #1257 by @icebob in #1269
- Add hook middlewares interceptors to preserve call context with call middlewares. by @DonVietnam in #1270
- Remove unnecessary clone in node update method by @Ubitso in #1274
New Contributors
- @Freezystem made their first contribution in #1260
- @DonVietnam made their first contribution in #1270
Full Changelog: v0.14.32...v0.14.33
v0.14.32
What's Changed
- Update peer dependency for mqtt to 5.0.2 by @mze9412 in #1236
- add d.ts for class Runner (MoleculerRunner) by @0x0a0d in #1245
- Update index.d.ts with Middlewares.Transmit type definitions by @0x0a0d in #1246
- fix memory leak by @ghostiee in #1243
- imp(index.d.ts): middleware serviceCreating params by @0x0a0d in #1248
New Contributors
Full Changelog: v0.14.31...v0.14.32
v0.14.31
What's Changed
- Remove usage of _.uniq by @MrDroid1 in #1211
- Fix: prometheus reporter to accept host option by @MichaelErmer in #1221
- Bugfix: started not being called when createService is used by @MichaelErmer in #1229
New Contributors
- @MichaelErmer made their first contribution in #1221
Full Changelog: v0.14.30...v0.14.31
v0.14.30
What's Changed
- Improve logger types by @shawnmcknight in #1208
- add typings to package.json export by @cs4inctec in #1210
- Remove usage of _.random by @MrDroid1 in #1212
- replace deprecated redis.setex with redis.set method by @fernandodevelon in #1191
- Update some registry types around ActionCatalog by @shawnmcknight in #1225
New Contributors
- @cs4inctec made their first contribution in #1210
- @MrDroid1 made their first contribution in #1212
- @fernandodevelon made their first contribution in #1191
Full Changelog: v0.14.29...v0.14.30
v0.14.29
What's Changed
- Improve lifecycle handler types by @shawnmcknight in #1179
- chore(types): add service list options & define getActionList type by @lucduong in #1182
- fix: do not emit send node info during broker stopping event by @alvaroinckot in #1186
- Updated Datadog metrics by @bcavlin in #1156
- chore(types): mergeSchema can be used to merge 2 mixins by @0x0a0d in #1187
- Allow opt out of redlock in redis cacher by @shawnmcknight in #1192
New Contributors
Full Changelog: v0.14.28...v0.14.29
v0.14.28
What's Changed
- fix no clean exit on shutdown, with disableBalancer: true #1168
- change
__proto__
toObject.getProtoTypeOf
#1170 - fix merge schemas (handling nulls) #1172
- fix hot reload error handling #1174
- update d.ts file
- update dependencies
New Contributors
- @danieledraganti made their first contribution in #1173
- @gautaz made their first contribution in #1170
Full Changelog: v0.14.27...v0.14.28
v0.14.27
What's Changed
- feat(TS/cachers): add types for lock functions by @thib3113 in #1152
- Typing add spanName and safeTags to tracing options by @thib3113 in #1157
- Use interface instead of type to allow for declaration merging by @shawnmcknight in #1165
- Prevent registerInternalServices deprecation warning by @DenisFerrero in #1163
New Contributors
- @DenisFerrero made their first contribution in #1163
Full Changelog: v0.14.26...v0.14.27