pub struct Episode<B: Behavior> { /* private fields */ }Expand description
A set of actors brought into being together, wired to one another as their inits allow, and run until every one of them has stopped.
Implementations§
Source§impl<B: Behavior> Episode<B>
impl<B: Behavior> Episode<B>
Sourcepub fn new(init: HashMap<ActorId, ActorInit<B>>, logger: Logger<B::Log>) -> Self
pub fn new(init: HashMap<ActorId, ActorInit<B>>, logger: Logger<B::Log>) -> Self
The actors described by init, wired to one another as it allows.
Those with has_logger get a copy of logger.
§Panics
Panics when an init’s can_send_to or can_shut_down names an actor
missing from init. An episode’s wiring is checked when it is built.
Sourcepub async fn run(self, patience: Duration) -> Result<()>where
B: 'static,
pub async fn run(self, patience: Duration) -> Result<()>where
B: 'static,
Spawn every actor, wait until all of them are initialized and running
their message loops, then tell each one to start, and wait for all of
them to finish. Once patience runs out, shut down every actor still
running and fail.
Every actor is ready before any actor starts, so an opening move always lands on an actor that is running.
§Errors
The first actor to fail shuts the others down, and its error is the episode’s. An actor that fails to initialize fails the episode before any actor starts. Running out of patience is an error too.