Search code examples
moleculer

Moleculer: segmenting micro service communication


I just starting playing with Moleculer and saw how easy it is to call a service actions/events from another service. This is great. However, is there a way to limit which services can access particular services? So for example if I have products and orders in my app, I may not want the orders accessing all the product related services, just the main one. I am just thinking that if I leave it free for all, maintainability may suffer as I won't easily know which service is calling which service. Or should I just create two projects (one for orders and one for products) and control it there?


Solution

  • You could use the namespace property in broker. From the docs:

    Namespace of nodes to segment your nodes on the same network.

    https://moleculer.services/docs/0.13/broker.html#Broker-options

    And then you could use inter namespace middleware https://gist.github.com/icebob/c0bce54436379d29c1bee8521ceb5348

    Anyway, you might consider using Discord chat (https://discord.gg/TSEcDRP). Moleculer community is much more active there.