Moleculer v0.14.0-rc1 Release Notes
Release Date: 2020-01-26 // over 4 years ago-
Minimum Node version is 10 (BREAKING)
The Node version 8 LTS lifecycle has been ended on December 31, 2019, so the minimum required Node version is 10.
Bluebird dropped (BREAKING)
The Bluebird Promise library has been dropped from the project because as of Node 10 the native
Promise
implementation is faster (2x) than Bluebird.Nonetheless, you can use your desired Promise library, just set the
Promise
broker options.Using Bluebird
const BluebirdPromise = require("bluebird");// moleculer.config.jsmodule.exports = { Promise: BluebirdPromise };
โฑ > Please note, the given Promise library will be polyfilled with
delay
,method
,timeout
andmapSeries
methods (which are used inside Moleculer core modules).๐ Better service event handler testing
โ Service class has a new
emitLocalEventHandler
method in order to call a service event handler directly. It can be useful in Unit Tests because you don't need to emit an event withbroker.emit
.Example
// posts.service.jsmodule.exports = { name: "posts", events: { async "user.created"(ctx) { this.myMethod(ctx.params); } } }; // posts.service.spec.jsdescribe("Test events", () =\> { const broker = new ServiceBroker({ logger: false }); const svc = broker.createService(PostService); beforeAll(() =\> broker.start()); afterAll(() =\> broker.stop()); describe("Test 'user.created' event", () =\> { beforeAll(() =\> svc.myMethod = jest.fn()); afterAll(() =\> svc.myMethod.mockRestore()); it("should call the event handler", async () =\> { await svc.emitLocalEventHandler("branch.closed", { a: 5 }); expect(svc.myMethod).toBeCalledTimes(1); expect(svc.myMethod).toBeCalledWith({ a: 5 }); }); }); });
๐ Stream
objectMode
support๐ Thanks for @artur-krueger, the request & response streams support
objectMode
, as well. You can also send Javascript objects via streams.Example
Other changes
- 0๏ธโฃ In metrics, the
defaultBuckets
value has been changed to milliseconds. - add
caller
label for EVENT_RECEIVED_TOTAL metric. - the heartbeat logic can be disabled by
heartbeatInterval: 0
broker option. - โ remove the new
currentContext
property inService
&ServiceBroker
. - in Service instances the original schema (before applying mixins) is available via
this.originalSchema
.
- 0๏ธโฃ In metrics, the