pub struct ActivityContext { /* private fields */ }Expand description
Handler-facing context for one activity execution.
Implementations§
Source§impl ActivityContext
impl ActivityContext
Sourcepub fn new(
activity_id: ActivityId,
attempt: u32,
) -> (Self, ActivityCancellationHandle)
pub fn new( activity_id: ActivityId, attempt: u32, ) -> (Self, ActivityCancellationHandle)
Creates a context and the internal handle that can signal cancellation.
Sourcepub const fn activity_id(&self) -> &ActivityId
pub const fn activity_id(&self) -> &ActivityId
Returns this activity’s identifier.
Sourcepub fn heartbeat(&self, detail: Option<Payload>) -> Result<(), WorkerError>
pub fn heartbeat(&self, detail: Option<Payload>) -> Result<(), WorkerError>
Emits a cooperative heartbeat request for this activity.
This is the PROGRESS channel: handlers call it to attach a progress payload to the activity’s liveness record. LIVENESS itself is owned by the worker runtime, which automatically heartbeats every in-flight activity within the server-assigned heartbeat window — a handler that never calls this still stays live for as long as it genuinely runs. Contexts created without a live heartbeat sender remain no-op contexts for isolated unit tests.
§Errors
Returns WorkerError when an installed heartbeat seam has been closed
or when the context lacks the workflow id required by the live session.
Sourcepub fn emit_event(&self, event: ActivityEvent) -> Result<(), WorkerError>
pub fn emit_event(&self, event: ActivityEvent) -> Result<(), WorkerError>
Emit a neutral agent-observability ActivityEvent onto the transcript
seam (NOI-5b).
Additive and OPTIONAL: on a context created without a live event seam
(every isolated unit test, and every activity that does not run an
instrumented agent) this is a no-op returning Ok(()), so behaviour is
byte-identical to today. When a seam is installed the worker runtime drains
these events and forwards them to the server’s transcript sequencer, which
stamps the commit-allocated store_seq — the producer never assigns it.
Harness-neutral: the payload is a pure aion-core ActivityEvent; the
per-harness mapping lives in the worker-side adapter, never here.
§Errors
Returns WorkerError when an installed event seam has been closed (the
runtime drain end was dropped) — a dropped transcript event is surfaced,
never silently swallowed.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true once cooperative cancellation has been signalled.
Trait Implementations§
Source§impl Clone for ActivityContext
impl Clone for ActivityContext
Source§fn clone(&self) -> ActivityContext
fn clone(&self) -> ActivityContext
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 Freeze for ActivityContext
impl RefUnwindSafe for ActivityContext
impl Send for ActivityContext
impl Sync for ActivityContext
impl Unpin for ActivityContext
impl UnsafeUnpin for ActivityContext
impl UnwindSafe for ActivityContext
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> 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