Skip to content

Releases: moleculerjs/moleculer

v0.14.35

06 Nov 17:38
Compare
Choose a tag to compare

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

Full Changelog: v0.14.34...v0.14.35

v0.14.34

28 Jul 12:01
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.14.33...v0.14.34

v0.15.0-beta1

06 May 16:49
Compare
Choose a tag to compare
v0.15.0-beta1 Pre-release
Pre-release

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 to customCommands, 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 (nats@1.x.x) implementation

The legacy nats@1.x.x transporter implementation is removed. This version supports only nats@2.x.x 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. Use broker.Promise or this.Promise inside a Service.

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"
  ...
Read more

v0.14.33

02 Apr 15:37
Compare
Choose a tag to compare

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

Full Changelog: v0.14.32...v0.14.33

v0.14.32

12 Nov 18:07
Compare
Choose a tag to compare

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

06 Aug 13:53
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.14.30...v0.14.31

v0.14.30

15 Jul 17:08
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.14.29...v0.14.30

v0.14.29

12 Mar 19:54
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.14.28...v0.14.29

v0.14.28

08 Jan 15:45
Compare
Choose a tag to compare

What's Changed

  • fix no clean exit on shutdown, with disableBalancer: true #1168
  • change __proto__ to Object.getProtoTypeOf #1170
  • fix merge schemas (handling nulls) #1172
  • fix hot reload error handling #1174
  • update d.ts file
  • update dependencies

New Contributors

Full Changelog: v0.14.27...v0.14.28

v0.14.27

17 Dec 16:29
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.14.26...v0.14.27