Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into runner-esm
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Apr 23, 2022
2 parents 5d32712 + f5bfbc6 commit 800030a
Show file tree
Hide file tree
Showing 36 changed files with 13,028 additions and 14,171 deletions.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<a name="Unreleased"></a>
# [Unreleased](https://github.com/moleculerjs/moleculer/compare/v0.14.19...master)
# [Unreleased](https://github.com/moleculerjs/moleculer/compare/v0.14.20...master)

# Changed
- `broker.stopping` property is created to indicate that broker is in stopping state.

--------------------------------------------------
<a name="0.14.20"></a>
# [0.14.20](https://github.com/moleculerjs/moleculer/compare/v0.14.19...v0.14.20) (2022-04-19)

_52 commits from 8 contributors._

## Dependency logic changed [#1077](https://github.com/moleculerjs/moleculer/issues/1077)

In [mixed architecture](https://moleculer.services/docs/0.14/clustering.html#Mixed-architecture), it's not hard to create a circular service dependency that may cause a dead-lock during the start of Moleculer nodes. The problem is that Moleculer node only sends the local service registry to remote nodes after **all** local services started properly.
As of 0.14.20, this behavior has changed. The new logic uses a debounced registry sending method which is triggered every time a local service, that the node manages, has `started()`.
Note that the new method generates more [INFO packets](https://github.com/moleculer-framework/protocol/blob/master/4.0/PROTOCOL.md#info), than early versions, during the start of the node. The number of INFO packets depends on the number of the services that the node manages. The debounce timeout, between sending INFO packets, is 1 second.

## Other Changes
- fix ActionLogger and TransitLogger middlewares.
- update Datadog Logger using v2 API. [#1056](https://github.com/moleculerjs/moleculer/pull/1056)
- update dependencies.
- update d.ts file. [#1064](https://github.com/moleculerjs/moleculer/pull/1064), [#1073](https://github.com/moleculerjs/moleculer/pull/1073)
- fix pino child logger bindings. [#1075](https://github.com/moleculerjs/moleculer/pull/1075)


--------------------------------------------------
<a name="0.14.19"></a>
Expand Down
2 changes: 1 addition & 1 deletion benchmark/suites/serializers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let dataFiles = ["10", "1k", "50k", "100k", "buf-10240", "buf-102400"];
function runTest(dataName) {
let payload = !dataName.startsWith("buf-")
? JSON.parse(getDataFile(dataName + ".json"))
: crypto.randomBytes(parseInt(dataName.substr(4)));
: crypto.randomBytes(parseInt(dataName.substring(4)));

const broker = new ServiceBroker({ logger: false });

Expand Down
2 changes: 1 addition & 1 deletion dev/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function inspect(x) {
rv = x.constructor.name;
}
if (typeof x === "object") {
rv += ". Keys: " + Object.keys(x).join(", ").substr(0, 80);
rv += ". Keys: " + Object.keys(x).join(", ").substring(0, 80);
}
return rv;
}
141 changes: 141 additions & 0 deletions dev/remote-deps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
"use strict";

const ServiceBroker = require("../src/service-broker");
const Middlewares = require("../src/middlewares");

const broker1 = new ServiceBroker({
nodeID: "node-1",

transporter: "TCP",

registry: {
discoverer: "Local"
// discoverer: "Redis"
// discoverer: "Etcd3"
}

// middlewares: [
// Middlewares.Debugging.TransitLogger({
// logPacketData: true,
// folder: null,
// colors: {
// send: "magenta",
// receive: "blue"
// },
// packetFilter: ["HEARTBEAT"]
// })
// ]
});

const broker2 = new ServiceBroker({
nodeID: "node-2",

transporter: "TCP",

registry: {
discoverer: "Local"
// discoverer: "Redis",
// discoverer: "Etcd3"
}

// middlewares: [
// Middlewares.Debugging.TransitLogger({
// logPacketData: true,
// folder: null,
// colors: {
// send: "magenta",
// receive: "blue"
// },
// packetFilter: ["HEARTBEAT"]
// })
// ]
});

const locationSchema = {
name: "location",

// depends on device.service at node-2
dependencies: ["device"],

async started() {
this.logger.info("Location Services started");
}
};

const tenantSchema = {
name: "tenant",

actions: {
add: {
handler(ctx) {
return "tenant.add action";
}
}
},

async started() {
this.logger.info("Tenant Services started");
}
};

const assetSchema = {
name: "device",

// Depends on tenant.service located at node-1
dependencies: ["tenant"],

async started() {
this.logger.info("Device Services started");

const result = await this.broker.call("tenant.add");

this.logger.info("RESPONSE FROM TENANT =>", result);
}
};

// Place location.service and tenant.service at node-1
broker1.createService(locationSchema);
broker1.createService(tenantSchema);

// Place asset.service at node-2
broker2.createService(assetSchema);
/*broker2.createService({
name: "test1",
dependencies: ["location", "device"],
started() {
return this.Promise.delay(2000);
}
});
broker2.createService({
name: "test2",
dependencies: ["location", "tenant"],
started() {
return this.Promise.delay(3000);
}
});
broker2.createService({
name: "test3",
dependencies: ["tenant", "device"],
started() {
return this.Promise.delay(1000);
}
});
broker2.createService({
name: "test4",
dependencies: ["test3"],
started() {
return this.Promise.delay(500);
}
});
broker2.createService({
name: "test5",
started() {
return this.Promise.delay(2500);
}
});*/

Promise.all([broker1.start(), broker2.start()])
.then(() => {
broker1.repl();
})
.catch(err => console.log(err));
Loading

0 comments on commit 800030a

Please sign in to comment.