pub struct Pause(/* private fields */);Expand description
A request to park the run at its next node boundary.
Cloning is how the request travels: the loop keeps one handle and hands a
clone to each Runner, and every clone points at the same flag. There
is no channel because there is nothing to send - the only message is
“park”, it is idempotent, and a flag cannot be missed by a receiver that
was not listening yet.
The boundary is what makes this cheap. Every node writes the run’s state
before the next one starts, and every node skips what is already recorded:
prep returns early once candidates exist, implement asks only the seats
with nothing on disk, judge returns early once judgements exist. So a
parked run resumes into exactly the node it stopped before, and no agent
work is thrown away. Killing the process mid-node, by contrast, loses
whatever the seats in flight had not yet written - which for an implement
wave is an hour of paid work.
A Runner watches two independent handles of this type - see
Runner::on_pause and Runner::watch_interrupt - never one shared
between them. magi serve’s own shutdown (Stop::park) hands out one
clone covering the whole daemon’s lifetime and is never asked to un-park,
which is correct exactly because nothing is dispatched after it fires.
magi serve’s interrupt scheduler needs the opposite lifetime - a run
that parks for an interrupted task must go on to run other tasks
afterward - so it mints a fresh, unshared Pause per run instead of
reusing the daemon-wide one.
Implementations§
Source§impl Pause
impl Pause
Sourcepub fn park_because(&self, reason: impl Into<String>)
pub fn park_because(&self, reason: impl Into<String>)
Same as Pause::park, but records why, for Runner::park_here to
fold into the run’s own park event - so an operator reading the run
later knows this was a deliberate interrupt rather than a shutdown or
a binary swap. The first reason recorded wins; a park already in
flight is not relabelled by a second, unrelated request.
Sourcepub fn reason(&self) -> Option<String>
pub fn reason(&self) -> Option<String>
Why the park was asked for, when the caller used Pause::park_because.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pause
impl RefUnwindSafe for Pause
impl Send for Pause
impl Sync for Pause
impl Unpin for Pause
impl UnsafeUnpin for Pause
impl UnwindSafe for Pause
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more