You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Hi! I am trying to achieve some kind of isolation in my actor system, where the actors sending messages to other actors don't know about the receiver's message type but only know that it can accept messages of type T. For example:
In this case I would want the Actor1 only to send messages A to Actor3, and Actor2 only to send messages B. This way I could seamlessly change implementation of Actor3 (for example, switch Actor3.1 and Actor3.2) without changing anything about Actor1 and Actor2.
Describe the solution you'd like
It would be great if I could create ActorRef<A> and ActorRef<B> to pass it to Actors that are supposed to talk to Actor3. Actor3's message can implement From<A> and From<B>, so before calling send_message it would be able to cast the incoming message to the actual message type Actor3 could receive. I think currently it is not possible because of the runtime type check in send_message: if self.id.is_local() && self.type_id != std::any::TypeId::of::<TMessage>()
Describe alternatives you've considered
One alternative thing that is easy to do is to create a trait wrapping the ActorRef and use it instead but this seems hacky.
This is a really neat idea! I think we would need to introduce a new type however, something like FromActorRef<T> (the naming isn't final obviously). But yeah, I don't think this is something that can be done directly on an actor ref, but should be something we can add as a wrapper. It would be handy, since you could do stuff like
let actor: ActorRef<A>: ...;
let type_b: FromActorRef<B> = actor.clone().from();
let type_c: FromActorRef<C> = actor.clone().from();
Is your feature request related to a problem? Please describe.
Hi! I am trying to achieve some kind of isolation in my actor system, where the actors sending messages to other actors don't know about the receiver's message type but only know that it can accept messages of type T. For example:
In this case I would want the Actor1 only to send messages A to Actor3, and Actor2 only to send messages B. This way I could seamlessly change implementation of Actor3 (for example, switch Actor3.1 and Actor3.2) without changing anything about Actor1 and Actor2.
Describe the solution you'd like
It would be great if I could create
ActorRef<A>
andActorRef<B>
to pass it to Actors that are supposed to talk to Actor3. Actor3's message can implementFrom<A>
andFrom<B>
, so before calling send_message it would be able to cast the incoming message to the actual message type Actor3 could receive. I think currently it is not possible because of the runtime type check in send_message:if self.id.is_local() && self.type_id != std::any::TypeId::of::<TMessage>()
Describe alternatives you've considered
One alternative thing that is easy to do is to create a trait wrapping the
ActorRef
and use it instead but this seems hacky.Please let me know if there's already a good way to do this and I missed it. Thanks for your help!
The text was updated successfully, but these errors were encountered: