-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add remote actors to the name registry #103
base: main
Are you sure you want to change the base?
Conversation
So I actually thought about this when writing all the remote actor logic (I should probably have written it down somewhere when I thought about it lol). What are your thoughts on if there's already an actor with the same name registered? I.e. Node A then joins Node B, which trying to re-register the same name will fail. What are your thoughts on that? |
Right now, I think it'd fail to spawn the relevant |
I've spent some time thinking about this, and I think there are a few different options going forward:
My personal opinion is that option 2 is the most flexible and reliable, but the significant overlap with process groups may mean that it may not be worth implementing. |
This was essentially where I settled when I first wrote the functionality. However I believe Erlang does indeed support globally addressable actors, i.e. global in a full cluster like this. So it should theoretically be possible. Let me look into how they did it, and see if we can replicate that kind of functionality. |
Hey, has there been any progress on this topic? I am currently trying to achieve the following:
Actor A casts a message and a reference of Actor B to the remote Actor C.
|
So the problem you're going to have here is You could send an ActorId over the wire, with just the local pid, and when you receive it extract the node which it was sent from. That would let you construct the address of the actor Server A is connected to B, and A views B as it's "node 1". If A.actor_1 sends a message to B.actor_2 with the address of A.actor_3, actor_3 is local to 0 and therefore will have a node id of 0. You want to send 1.<actor_3_pid> to B, so that when B looks it up in its PID registry, it can find the actor_3 which is on its "node 1" (A). I'm not sure that's super clear, and cross-node addressing is actually quite painful, so it's not a trivial problem unfortunately. |
Basically, all you need to communicate between actors is a task/actor UUID/name. A node has a router that listens for incoming messages. A message is in a common "se/deserializable" format. An incoming message contains the destination task/actor UUID. The router passes a raw message to the (local) distributor/dispatcher. The distributor/dispatcher sends the message to the (local) target actor. The message also contains the sender UUID. The question is how would you like to implement the transport. zmq works pretty well for this kind of tasks. How the distributed actors know the hosts of each other actors? I guess the Erlang paradigm offers many solutions :) Preconfigured (if you have "small enough" amount of nodes), the central "actor discovery" facility, other types of brokers. I personally prefer direct connections where it's possible. But brokers could serve as node info distribution instruments. |
This PR registers remote actors into the node's local registry, and adds an integration test to demonstrate that this works.