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

Sending messages across cluster #2

Closed
gmile opened this issue Oct 22, 2016 · 1 comment
Closed

Sending messages across cluster #2

gmile opened this issue Oct 22, 2016 · 1 comment

Comments

@gmile
Copy link

gmile commented Oct 22, 2016

Right now libcluster doesn't seem to be able to send messages across cluster. From what I can tell after looking at :publish implementation, the event is only sent to subscribers, which are processes on that same node, but not nodes in cluster (correct me if I'm wrong).

I am using epmd strategy. The way I'm testing it is this:

  1. Run nodes:

    $ iex --sname node1@localhost --cookie test_cookie -S mix
    $ iex --sname node2@localhost --cookie test_cookie -S mix
  2. Connect nodes:

    iex(node1@localhost)1> Cluster.Strategy.connect_nodes([:'node2@localhost'])
    iex(node2@localhost)1> Cluster.Strategy.connect_nodes([:'node1@localhost'])
  3. Subscribe both shells to cluster events:

    iex(node1@localhost)2> Cluster.Events.subscribe(self())
    iex(node2@localhost)2> Cluster.Events.subscribe(self())
  4. Publish event from within node1:

    iex(node1@localhost)3> Cluster.Events.publish({:ok, "Hello, world!"})
    
    15:04:34.703 [debug] [libcluster] [events] <== {:publish, {:ok, "Hello, world!"}}
    :ok
    
  5. Flush shell messages on both nodes:

    on node1:

    iex(node1@localhost)4> flush()
    {:ok, "Hello, world!"}
    :ok
    iex(node1@localhost)5>
    

    and on node2:

    iex(node2@localhost)3> flush()
    :ok
    

Was this done by design? If so, what is the purpose of publishing events within the same node?

At the same time nodeup and nodedown events work perfectly across the cluster.

Is there a plan to support publishing arbitrary events across cluster? If so, I'd like to work on a PR to bring this support.

@bitwalker
Copy link
Owner

I've removed Cluster.Events from libcluster as part of the 2.0 effort to bring libcluster into alignment with firenest. libcluster is really intended to only provide the means by which you cluster nodes, beyond that though, things like firenest will be where you go for distributed pub/sub. Currently, swarm can work as a distributed pub/sub library, but firenest is going to be a better solution for that when it is released.

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

No branches or pull requests

2 participants