slawlor / ractor

Rust actor framework
MIT License
1.31k stars 68 forks source link

Full Example of Remote Actors with Supervision Trees #126

Closed daveman1010221 closed 11 months ago

daveman1010221 commented 1 year ago

I've read a lot of the existing tests and example code and much (all?) of the documentation on ractor_cluster and RactorClusterMessage and I haven't been able to figure out how to get past problems with BytesConvertable.

It's not clear which trait bounds I haven't satisfied when I attempt to work with something like:

MidLevelActorMessage::GetLeaf( RpcReplyPort<ActorRef<LeafActorMessage>> )

I started with an existing example, the one that shows how to create a supervision tree, and then extend that to have the Actors be accessible from a different node, by deriving RactorClusterMessage and annotating GetLeaf with #[Rpc].

An example of how to use this code would be very helpful.

slawlor commented 11 months ago

so right now supervision isn't supported across the cluster boundary. You can send RPC's across the boundary, but serialization of an ActorRef isn't right now possible. Unlike in Erlang, where any actor is just defined by its PID, we have the ActorRef contain a significantly larger amount of information (state of the actor, the messaging channel, etc). This is what allows us to not require our own runtime mapping of PID -> actor. With just an ActorRef you can contact any actor without any runtime or something, or a global dictionary PID lookup.

This isn't as flexible, but has added guarantees like type safety etc.

In this specific example, it's because ActorRef<_> or even ActorCell is not directly serializable.