Skip to main content

DeclaredCommandAttempts

Struct DeclaredCommandAttempts 

Source
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

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> DeclaredCommandAttempts

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeclaredCommandAttempts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoMaybeUndefined<T> for T

Source§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
Source§

impl<T> IntoOption<T> for T

Source§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more