pub struct ShutdownCoordinator<B: Behavior, C: Behavior, Occurrence>{ /* private fields */ }Expand description
Pure phased shutdown wrapper over an explicitly validated homogeneous child topology.
B is the wrapped coordinator behavior and C is the one concrete child
protocol selected by every creation ID in the plan. Starting a phase emits one
typed ShutdownChild<C, Occurrence> request per member in plan order. A phase advances
only after every matching ChildStopped fact arrives. An acceptance
rejection returns ShutdownCoordinatorError::ChildRejected without
changing the phase. A stale or foreign child fact is returned intact as a
typed error. This is Bombay lifecycle policy, not an actor-model allocation
or ordering guarantee.
The fold introduces no panic conditions.
A child protocol without the shutdown input cannot form an executable coordinator:
struct Plain;
impl behavior::Protocol for Plain {
type Addr = behavior::MailAddr;
type Msg = ();
}
impl behavior::Behavior for Plain {
type Protocol = Self;
type Event = behavior::User<behavior::MailAddr, ()>;
type Sends = Vec<behavior::Never>;
type Ph = behavior::Never;
type Error = behavior::Never;
type Birth = behavior::NoBirths;
fn transition(&mut self, _: behavior::ActiveTurn, _: Self::Event) -> behavior::BehaviorActed<Self> {
Ok(behavior::Actions::cont())
}
}
fn require_behavior<B: behavior::Behavior>(_: B) {}
let child = behavior::CreationSequence::new()
.issue()
.expect("the first child creation ID exists");
let plan = behavior_actors::ShutdownPlan::new([vec![child]]).unwrap();
require_behavior(behavior_actors::ShutdownCoordinator::<Plain, Plain, behavior::ChildHead>::new(Plain, plan));Implementations§
Source§impl<B: Behavior, C: Behavior, Occurrence> ShutdownCoordinator<B, C, Occurrence>
impl<B: Behavior, C: Behavior, Occurrence> ShutdownCoordinator<B, C, Occurrence>
pub const fn new(inner: B, plan: ShutdownPlan<CreationId>) -> Self
Sourcepub const fn awaiting_plan(inner: B) -> Self
pub const fn awaiting_plan(inner: B) -> Self
Start the wrapper before committed child creation can supply its plan.
InstallShutdownPlan later installs exactly one validated plan. A
shutdown request received first is retained by the state machine and
begins that plan immediately on installation.