Derived actor from cell#372
Conversation
|
|
||
| /// Retrieve the current status of an [super::Actor] | ||
| /// | ||
| /// Returns the [super::Actor]'s current [ActorStatus] |
| @@ -0,0 +1,258 @@ | |||
|
|
|||
| SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS | |||
There was a problem hiding this comment.
uhm what is all this gibberish? This shouldn't be in the repository
| cluster = [] | ||
| monitors = [] | ||
| message_span_propogation = [] | ||
| derived-actor-from-cell = [] |
There was a problem hiding this comment.
I haven't fully reviewed this PR, but if this is additive, we probably don't need a feature gate. People can choose to use it or not
| #[cfg(feature = "cluster")] | ||
| supports_remoting: TActor::Msg::serializable(), | ||
| #[cfg(feature = "derived-actor-from-cell")] | ||
| derived_provider: Box::new(DerivedProviderType::<TActor>::new()), |
There was a problem hiding this comment.
ah ok this isn't additive, so the feature is necessary
|
|
||
| /// Return a [DerivedActorRef<T>] from an [ActorCell]. | ||
| /// | ||
| /// This is usefull in scenario where the actual actor message type is unknown |
There was a problem hiding this comment.
nit: usefull in scenario -> useful in scenarios
| /// not provide this specific [DerivedActorRef] then this function will return | ||
| /// [None]. | ||
| /// | ||
| /// # Exemple |
| } | ||
| } | ||
|
|
||
| /// Type used as argument to [Message::proved_derived_actor_ref] |
| state.send(message).await?; | ||
| Ok(()) | ||
| } | ||
| fn provide_derived_actor_ref<'a>( |
There was a problem hiding this comment.
why can't this be a trait defined on the message type, rather the actor type? An actor who supports derived messages, should support them in aggregate as the messages can be natively converted IMHO.
I.e. if message type A supports derived types B, and C, all actors of message A should support derived message types B and C along with this new from-cell functionality.
This is a proposal for a new feature. I do need it in production right now so I implemented it and I propose it here as I think it can be useful.
It allows actor cells to "provide" valid DerivedActorRef. For example this is the test of this new feature included in this pull request:
For this to work, implementor of actor must implement a new fonction in Actor:
By default this method does nothing, so actor_cell.provide_derived() always return None if the referenced actor does not overrides this method.
In my case I need this because I want to put in groups actors that have different message type but that all can provide the same DerivedActorRef type.
The implementation looks quite unsafe, but this is superficial adaptation of the standard library code used to extract backtraces from errors in nightly.