Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should Commanded.Event.Handler support messages from swarm? #532

Open
tomekowal opened this issue May 12, 2023 · 2 comments
Open

Should Commanded.Event.Handler support messages from swarm? #532

tomekowal opened this issue May 12, 2023 · 2 comments

Comments

@tomekowal
Copy link

When I connect a new node to the cluster, I get a bunch of messages like this:

2023-05-12T13:32:44.260Z pid=<0.4030.0> [error] MySubscriber received unexpected message: {:swarm, :die}

I am using CommandedSwarmRegistry.
AFAIU, Subscribers start on both nodes, and when the nodes connect, Swarm kills half of the subscribers on one node and half on the other so that each subscriber runs only once.

However, when reading the code, I saw that this message is logged, but the Event.Handler is not terminated.
https://github.com/commanded/commanded/blob/master/lib/commanded/event/handler.ex#L826

Is the consensus that Swarm is an officially supported registry? Then I could add handling of this and potentially other swarm messages.

@dvic
Copy link
Contributor

dvic commented May 12, 2023

Might be related to #512

@tomekowal
Copy link
Author

Only slightly: in the sense that it requires adding some more clauses to handle_info in the same place.
AFAIU, swarm does not send exit signals to other processes the same way as global registry does.
Instead, it sends messages and expects the process to be aware that it is managed by Swarm and react to those accordingly.
https://github.com/bitwalker/swarm#example

  def handle_info({:swarm, :die}, state) do
    {:stop, :shutdown, state}
  end

If Commanded wants to support swarm, we would need add handling of those messages to all process managed via the abstract Registry that can be resolved to either :global or :swarm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants