-
Notifications
You must be signed in to change notification settings - Fork 69
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
ActorSelection.select(..) + sel.try_tell(Send,...) using a non String Msg, the ActorSelection.try_tell(Send,...) failes #129
Comments
The problem here is, that selection gives you a impl Actor for SelectTestParam {
type Msg = SelectTestParamMsg;
...
} The problem is, that the system currently only tries to casts to the exact type, which fails because the types are not the same. Maybe it is possible to cast it to an |
In the meantime you can use the message type explicitly: // instead of sel.try_tell(Send, None); use:
sel.try_tell(SelectTestParamMsg::Send(Send), None); |
Hi @hardliner66, thank you. The solution worked out! |
To add to this, an If you use
You can almost always architect your system so that you use |
all of our examples currently directly reuse the do we have to pass that |
You can think of an actor system as a collection of contracts. Each actor behaves like a contract to provide a result based on state and behavior. The contract should be easy to read, with input and output, including types, well defined. This is why actor systems are popular with functional programming languages such as Erlang and Scala. By "looking up" an actor reference by path you are getting a variable from outside, e.g. not passed as a parameter. Actors are not queues, although they utilize them for message handling. There is also a more generic paradigm called Object-Capability Model, which provides rules that limit what an object can interact with. OCM states:
The Actor Model is very similar to this and actor purists will follow OCM to the die. Ultimately, the reason OCM fits so well for actors is that it makes nondeterministic systems (concurrent applications) appear to behave in a deterministic way, and so therefore easy to reason about. It is this set of characteristics that set the actor model apart from other concurrent systems such as queues and make it an ideal means by which to handle state concurrently. In terms of Rust, it fits the lifetime and ownership concepts quite nicely too. There's an excellent book that explains this and actor patterns: Reactive Messaging Patterns with the Actor Model. While the examples are provided in Scala, this very much applies to all languages using actors. |
this ⬆️ would make a good preface in the chapter on selection |
Wow - I spent about a good hour in the CLion debugger to ultimately realize the mailbox was rejecting my messages. I was shocked to see we don't return any messages (logs or otherwise) to help clue people into what's going on. I do think this should be documented somewhere - I ran into it w/o a selection and just trying to communicate back between actors in a hierarchy. |
I'm using the lates rust + latest riker version.
thread 'pool-thread-#12' panicked at 'called
Result::unwrap()
on anErr
value: ()', .....cargo\registry\src\github.com-1ecc6299db9ec823\riker-0.4.1\src\actor\selection.rs:105:29The panic is raced in this piece of code:
Where the message is not a string but a struct; like in my example: Send
All the String Messages are managed correctly. But if the "non"-String message is supposed to be sent, then an Err() occurs. However this is (in my opinion) not the primary issue. It's rather that the non-string messages handling that failed...
The text was updated successfully, but these errors were encountered: