tractor
Actor framework for Rust, modelled after Pony's actors:
-
Actors cannot deadlock! -
Sending a message to anActorcan never fail. -
No
asyncinActors. Behaviors cannot block. -
Actors are garbage collected. -
The implemention of
tractoris rather simple compared against other Actor implementations in Rust. -
It uses
tokiobut was usingasync_stdin the past.
Example
In Cargo.toml add tractor = "*" and tokio = "1.2.0".
use *;
More details
-
Actors have unbounded mailboxes andsendis non-blocking. -
Actors cannot be manually stopped. They terminate as soon as no further reference to them exists and their mailbox is empty. This implies that sending a message to anActorcan never fail except for running out of memory. To avoid overloading of anActoryou can check it's current length of it's mailbox. -
The behaviors of an
Actorhave no return value! As such,Actors do not support "waiting" for a result. To "simulate" Request/Response, pass theActors address in the message and respond to it. -
The behaviors of an
Actorare NOTasync fns!Asyncwould imply that the execution can "halt". Use an async actor (ActorBehaviorAsync/ActorHooksAsync) instead. -
NOTE: Any
Actorcycles will defeat the garbage collection ofActors.