pub struct DeclaredCommandAttempts { /* private fields */ }Expand description
The declared-command attempts this server is executing right now.
An entry exists for exactly as long as one attempt’s command is running:
Self::register returns a guard that removes it, so an attempt that
finished, failed, or panicked its way out cannot be signalled afterwards.
Keyed on the full AttemptKey — including the run — because a
continue-as-new chain reuses one workflow id across generations while
activity ordinals and attempt numbers restart, so a shorter key genuinely
COLLIDES: two generations’ attempts would be one entry, and registering the
second would replace the first’s handle with nothing left to stop it. The
run axis is what keeps them distinct here and what lets the cancel report
name which generation it stopped. Cancelling is still workflow-scoped, as it
is for workers (super::HeartbeatTracker::in_flight_for_workflow): a
cancelled workflow’s work stops in every generation of it.
Implementations§
Source§impl DeclaredCommandAttempts
impl DeclaredCommandAttempts
Sourcepub fn new(drain: DrainState) -> Self
pub fn new(drain: DrainState) -> Self
Build an empty registry that wakes drain’s activity-drained latch
whenever an executing attempt finishes.
The latch is required rather than optional for the same reason the dispatcher requires the registry itself: a construction path that could silently skip the wiring would recreate the drained-over-live-work bug the wiring exists to prevent, invisibly.
Sourcepub fn register(
&self,
key: AttemptKey,
cancellation: ActivityCancellationHandle,
) -> Result<DeclaredAttemptRegistration, ServerError>
pub fn register( &self, key: AttemptKey, cancellation: ActivityCancellationHandle, ) -> Result<DeclaredAttemptRegistration, ServerError>
Record that this server is executing key’s declared command, and hand
back the guard that keeps the entry alive.
The entry lives exactly as long as the returned
DeclaredAttemptRegistration. A second registration of the same key —
which would mean one attempt executing twice at once, and is a defect
wherever it came from — is refused rather than allowed to overwrite the
handle of a command still running, because an overwritten handle is an
attempt nothing can stop.
Registration is also the drain’s door: a draining server is refused
here, so a declared body — which no worker gate can park — cannot start
after aion server stop was requested. The draining check runs INSIDE
the registry lock, and the drain gate’s census takes the same lock, so
any registration that passed the check is visible to any census taken
after the drain began; there is no window in which the gate reads empty
while a command that beat the latch is about to start.
§Errors
Returns ServerError::LockPoisoned when the registry cannot be read,
ServerError::DrainingRefusedDeclaredAttempt when this server is
draining, and ServerError::DeclaredAttemptCollision when key is
already executing.
Sourcepub fn cancel_workflow(
&self,
workflow_id: &WorkflowId,
) -> Result<Vec<AttemptKey>, ServerError>
pub fn cancel_workflow( &self, workflow_id: &WorkflowId, ) -> Result<Vec<AttemptKey>, ServerError>
Signal every declared command this server is executing for workflow_id.
Returns the attempts signalled, in activity-then-attempt order, so the caller reports a stable list rather than whatever order the map yielded. An empty result means this server is executing none of the run’s bodies, which is the common case and is not a failure.
The entries are NOT removed here. Removing them is the executing attempt’s own act, on the guard it holds, once its process group is gone — and a cancel that deregistered an attempt it had merely signalled would make a second cancel a silent no-op against a command still dying.
§Errors
Returns ServerError::LockPoisoned when the registry cannot be read.
Not survivable: answering “this server is executing nothing for that run”
out of state that could not be read is exactly how a cancelled run keeps
a machine.
Sourcepub fn executing(&self) -> Result<Vec<AttemptKey>, ServerError>
pub fn executing(&self) -> Result<Vec<AttemptKey>, ServerError>
Every declared command this server is executing right now, in activity-then-attempt order.
§Errors
Returns ServerError::LockPoisoned when the registry cannot be read.
Trait Implementations§
Source§impl Clone for DeclaredCommandAttempts
impl Clone for DeclaredCommandAttempts
Source§fn clone(&self) -> DeclaredCommandAttempts
fn clone(&self) -> DeclaredCommandAttempts
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for DeclaredCommandAttempts
impl !UnwindSafe for DeclaredCommandAttempts
impl Freeze for DeclaredCommandAttempts
impl Send for DeclaredCommandAttempts
impl Sync for DeclaredCommandAttempts
impl Unpin for DeclaredCommandAttempts
impl UnsafeUnpin for DeclaredCommandAttempts
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request