pub struct ShutdownEstablished<B, TargetPath>where
B: Behavior,
BehaviorAddr<B>: EndpointAddress,
B::Event: InjectEvent<ShutdownRequested, TargetPath>,{
pub id: ShutdownId,
/* private fields */
}Expand description
Request orderly shutdown of one exact installed concrete behavior.
TargetPath proves where ShutdownRequested enters the installed
behavior’s closed event algebra. The interpreter receives that typed
ingress together with the exact installed actor; shutdown is therefore still an
explicit event/effect transformation, not a privileged runtime side
channel.
A concrete actor whose event algebra has no shutdown ingress cannot be strengthened into an orderly-shutdown request:
ⓘ
#[derive(Clone, Copy, PartialEq, Eq)]
struct RuntimeAddr(u64);
impl behavior::Address for RuntimeAddr { type Nonce = u64; }
struct Endpoint;
impl Clone for Endpoint { fn clone(&self) -> Self { Self } }
struct Installed<B: behavior::Behavior>(Endpoint, std::sync::mpsc::Sender<B::Event>);
impl<B: behavior::Behavior> Clone for Installed<B> {
fn clone(&self) -> Self { Self(self.0.clone(), self.1.clone()) }
}
impl behavior::EndpointAddress for RuntimeAddr {
type Established<P> = Endpoint where P: behavior::Protocol<Addr = Self>;
type Installed<B> = Installed<B>
where B: behavior::Behavior<Protocol: behavior::Protocol<Addr = Self>>;
fn recipient<B>(installed: &Self::Installed<B>) -> Endpoint
where B: behavior::Behavior<Protocol: behavior::Protocol<Addr = Self>> {
installed.0.clone()
}
}
struct Worker;
impl behavior::Protocol for Worker { type Addr = RuntimeAddr; type Msg = (); }
impl behavior::Behavior for Worker {
type Protocol = Self;
type Event = behavior::User<RuntimeAddr, ()>;
type Sends = behavior::NoSends;
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()) }
}
let (control, _inbox) = std::sync::mpsc::channel::<<Worker as behavior::Behavior>::Event>();
let actor = behavior::EstablishedActor::<Worker>::issued(Installed(Endpoint, control));
let _ = behavior_actors::ShutdownEstablished::<Worker, behavior::Here>::new(
behavior_actors::ShutdownId(1),
actor,
behavior::Ingress::<behavior_actors::ShutdownRequested, behavior::Here>::new(),
);Fields§
§id: ShutdownIdImplementations§
Source§impl<B, TargetPath> ShutdownEstablished<B, TargetPath>where
B: Behavior,
BehaviorAddr<B>: EndpointAddress,
B::Event: InjectEvent<ShutdownRequested, TargetPath>,
impl<B, TargetPath> ShutdownEstablished<B, TargetPath>where
B: Behavior,
BehaviorAddr<B>: EndpointAddress,
B::Event: InjectEvent<ShutdownRequested, TargetPath>,
pub const fn new( id: ShutdownId, actor: EstablishedActor<B>, ingress: Ingress<ShutdownRequested, TargetPath>, ) -> Self
Sourcepub fn actor(&self) -> EstablishedActor<B>
pub fn actor(&self) -> EstablishedActor<B>
Clone the exact actor capability without changing request ownership.
Sourcepub fn settle<I>(
self,
interpreter: &mut I,
) -> ItemSettlement<Self, ShutdownId, ShutdownRejection, Never>where
I: InterpretEstablishedShutdown<B, TargetPath>,
pub fn settle<I>(
self,
interpreter: &mut I,
) -> ItemSettlement<Self, ShutdownId, ShutdownRejection, Never>where
I: InterpretEstablishedShutdown<B, TargetPath>,
Attempt this request and return its one statically selected settlement.
Trait Implementations§
Source§impl<B, TargetPath> ActionItem for ShutdownEstablished<B, TargetPath>where
B: Behavior,
BehaviorAddr<B>: EndpointAddress,
B::Event: InjectEvent<ShutdownRequested, TargetPath>,
EstablishedActor<B>: Send,
impl<B, TargetPath> ActionItem for ShutdownEstablished<B, TargetPath>where
B: Behavior,
BehaviorAddr<B>: EndpointAddress,
B::Event: InjectEvent<ShutdownRequested, TargetPath>,
EstablishedActor<B>: Send,
type Custody = (Option<ShutdownEstablished<B, TargetPath>>, Option<<ShutdownEstablished<B, TargetPath> as ActionItem>::Reply>)
type Input<'a> = &'a mut Option<ShutdownEstablished<B, TargetPath>> where Self: 'a
type Reply = ItemSettlement<ShutdownEstablished<B, TargetPath>, <ShutdownEstablished<B, TargetPath> as ActionItem>::Accepted, <ShutdownEstablished<B, TargetPath> as ActionItem>::Rejection, <ShutdownEstablished<B, TargetPath> as ActionItem>::Prerequisite>
type Accepted = ShutdownId
type Rejection = ShutdownRejection
type Prerequisite = Never
fn prepare_interpretation( progress: &mut Option<InterpretationProgress<Self, Self::Custody, Self::Reply>>, )
fn interpretation_input<'a>(
custody: &'a mut Self::Custody,
) -> Option<(Self::Input<'a>, &'a mut Option<Self::Reply>)>where
Self: 'a,
fn finish_interpretation( progress: &mut Option<InterpretationProgress<Self, Self::Custody, Self::Reply>>, )
Source§impl<B, TargetPath> InterpreterRequest for ShutdownEstablished<B, TargetPath>where
B: Behavior,
BehaviorAddr<B>: EndpointAddress,
B::Event: InjectEvent<ShutdownRequested, TargetPath>,
impl<B, TargetPath> InterpreterRequest for ShutdownEstablished<B, TargetPath>where
B: Behavior,
BehaviorAddr<B>: EndpointAddress,
B::Event: InjectEvent<ShutdownRequested, TargetPath>,
type ReturnToEmitter = ReturnsToEmitter<EstablishedShutdownResolved<<B as Behavior>::Protocol>, Here>
type LogicalProtocols = NoBirthProtocols
Auto Trait Implementations§
impl<B, TargetPath> Freeze for ShutdownEstablished<B, TargetPath>
impl<B, TargetPath> RefUnwindSafe for ShutdownEstablished<B, TargetPath>
impl<B, TargetPath> Send for ShutdownEstablished<B, TargetPath>
impl<B, TargetPath> Sync for ShutdownEstablished<B, TargetPath>
impl<B, TargetPath> Unpin for ShutdownEstablished<B, TargetPath>
impl<B, TargetPath> UnsafeUnpin for ShutdownEstablished<B, TargetPath>
impl<B, TargetPath> UnwindSafe for ShutdownEstablished<B, TargetPath>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more