kalisio/feathers-distributed

Unreliable service discovery

Closed this issue · 2 comments

Using pub/sub to expose local Feathers services to other nodes is not reliable because it depends on the order of initialization of the different apps. Indeed, the messages publishers publish are volatile in that if there are no subscribers listening, they are lost.

cote provides onAdded/onRemoved methods or events to be aware of other nodes, it might be overridden/used to have a more reliable solution. Another solution is to use req/res paradigm because a requester will just queue the request until a responder is available. But this requires every node to dispatch the complete service sets (including remote the ones) because req/res uses round-robin and a single responder will answer the request. Not completely sure it will be dependent of the initialization order yet.

However, the whole point of cote is to keep you from managing lists of services: that’s what autodiscovery is. cote services already discover each other automatically, you shouldn’t need to implement your own solution here. We can't probably target this because we'd like to be able to deploy our Feathers apps with services as usual or be able to deploy them as microservices using the cote plugin when we'd like to. Moreover Feathers already provides REST/Socket endpoints/clients so we'd like to keep it like this by actually make it become a sort of API gateway, without the need of using cote clients.

Adding a third server instance with a remote service makes the bug appear in current tests.

Fixed by re-emitting the event each time a new node appears