This middleware can connect to other namespaces.
moleculer.config.js
const InterNamespaceMiddleware = require("./inter-namespace.js");
module.exports {
namespace: "local",
nodeID: "node-1",
transporter: "NATS",
middlewares: [
InterNamespaceMiddleware(["ns-mars", "ns-venus"])
]
}
moleculer.config.js
const InterNamespaceMiddleware = require("./inter-namespace.js");
module.exports {
namespace: "local",
nodeID: "node-1",
transporter: "NATS",
middlewares: [
InterNamespaceMiddleware([
{
namespace: "ns-mars",
transporter: "NATS"
},
{
namespace: "ns-venus",
transporter: "Redis",
}
])
]
}
// Call service in the local namespace
broker.call("greeter.hello");
// Call service in the local namespace with the namespace
broker.call("greeter.hello@local");
// Call service in the "ns-venus" namespace
broker.call("greeter.hello@ns-venus");
// Call service in the "ns-mars" namespace
broker.call("greeter.hello@ns-mars");
I have implemented a bit of adjustment for support load services per namespace just in case someone needs it like me :).