Cluster Singleton Grain Service? #9959
Replies: 2 comments 5 replies
-
|
Just spitballing, would a grain with a known, fixed ID (e.g. |
Beta Was this translation helpful? Give feedback.
-
|
I ran into this exact scenario last year when we needed a single MQTT bridge grain. The simplest Orleans‑native way is to mark the grain with If you need to run code on every silo as well (e.g. local metrics), layer fine |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So, I have a weird use case that i don't know if the in-box Orleans tools are a good fit for. Basically, i need a cluster-singleton persistent service. A Grain Service works just fine for this, except that it is replicated to all Silos (maybe they should be called Silo Services 😄).
I have taken to implementing a grain service, but with some fancy logic that basically elects a "leader" that directs the other follower instances. The "election" is just whatever Silo Address is sorted first in the list of active silos, which updates made on every ring size change. It kinda seems to work, but i wonder if there is a better way to tackle this?
The obvious alternative is to spawn an external "gateway" service outside of orleans that relays commands into the cluster, which works, but I was just curious if there was a way to handle this in an orleans native way.
The concrete usecase is a pub/sub subscription that needs to maintain a single persistent connection to the broker to send/receive commands.
Beta Was this translation helpful? Give feedback.
All reactions