StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.91k stars 1.51k forks source link

Cluster Broadcast #2333

Open shacharPash opened 1 year ago

shacharPash commented 1 year ago

I'm trying to create a broadcast option when using a cluster. It should look like that:

  1. Take an existing cluster / create one.
  2. Find all its master nodes.
  3. Send a certain command to all those master nodes.

This is necessary, for example, when I want to flush databases on all cluster nodes.

Is there a convenient built-in way to do this thing in StackExchange.Redis? And if not, how can it still be done?

NickCraver commented 1 year ago

We have a design for this in mind but likely not until January at best, basically instead of a function like this instead we'll offer an API to run a command on all nodes that's much more generic and allows a lot more flexible usages, e.g. flushing on all nodes would work the same way as broadcasting to all nodes. It's in work chat (I'm disconnected for the year), will grab notes when back :)

shacharPash commented 1 year ago

Awesome! can you share the design or a link to what you are thinking?

NickCraver commented 1 year ago

Chatted on this in our sync yesterday, we had a notion for how to do this, but it doesn't actually apply to subscription publishing due to the way that specifically works as a one-off item, so slight change of plan...though we may still add that API later, e.g. for flushing all servers in a cluster and other operations of that nature.

I'll try to throw up a PR for this during the week or weekend, but tl;dr: after poking at options it looks like a .PublishAllServers(...) (or some name) that allows filtering via CommandFlags (and an async version) is the way to go. @mgravell added the API I needed internally to make this a bit cleaner in #2337.

uglide commented 1 year ago

Hi @NickCraver Could you clarify whether @shacharPash can start working on this?