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");
@jellydn nice addition. I think you should add
middlewares: null
tobrokerOpts
else I think you will get an infinite broker creation loop.