Skip to main content

Context

Struct Context 

Source
pub struct Context { /* private fields */ }
Expand description

Provides invocation metadata and staged durable changes to Step and RPC handlers.

A Context belongs to one handler attempt and must not outlive the call. Attribute writes, Channel publications, locals, and events become visible atomically only when the handler returns successfully. Application values are freshly decoded and owned by the invocation.

Implementations§

Source§

impl Context

Source

pub fn flow_id(&self) -> &str

Returns the application-assigned Flow ID.

Source

pub fn run_id(&self) -> &str

Returns the server-assigned run ID for this execution.

Source

pub fn flow_started_at(&self) -> SystemTime

Returns when the current Flow run started.

Source

pub fn step_execution_id(&self) -> &str

Returns the current Step execution ID, or an empty string for an RPC.

Source

pub fn from_step_execution_id(&self) -> &str

Returns the predecessor Step execution ID, or an empty string when absent.

Source

pub fn first_attempt_at(&self) -> SystemTime

Returns when the first attempt of this handler invocation started.

Source

pub fn attempt(&self) -> u32

Returns the one-based handler attempt number.

Source

pub fn has_any_timer_fired(&self) -> bool

Returns whether any timer condition completed for this execute invocation.

Source

pub fn has_timer_fired(&self, index: usize) -> bool

Returns whether the zero-based timer at index completed.

Missing indexes return false.

Source

pub fn wait_for_method_failed(&self) -> bool

Returns whether execute is running because wait_for exhausted retries with Proceed.

Source

pub fn wait_for_cancellation(&self)

Blocks the current thread until Dex cancels this handler attempt.

Use this only for interruptible application work; ordinary handlers should return normally.

Source

pub fn is_cancelled(&self) -> bool

Returns immediately with the current handler-cancellation state.

Source

pub fn set_step_execution_local<T: Value>( &mut self, key: &str, value: T, ) -> HandlerResult<()>

Stages a Step-execution-local value visible to later attempts of the same execution.

§Errors

Returns HandlerError for an empty key or an encoding failure.

Source

pub fn step_execution_local<T: Value>(&self, key: &str) -> HandlerResult<T>

Reads a required Step-execution-local value, including writes staged by this attempt.

§Errors

Returns HandlerError for an empty key, a missing value, or a decoding failure.

Source

pub fn record_event<T: Value>( &mut self, name: &str, value: T, ) -> HandlerResult<()>

Records one named diagnostic event with a typed payload.

Event names must be unique within the invocation.

§Errors

Returns HandlerError for an empty or duplicate name or an encoding failure.

Source

pub fn get_attribute<T: Value>( &self, attribute: &Attribute<T>, ) -> HandlerResult<Option<T>>

Reads an Attribute value, including writes staged by this invocation.

Source

pub fn get_attribute_map<T: Value>( &self, attribute: &AttributeMap<T>, instance: &str, ) -> HandlerResult<Option<T>>

Reads one Attribute-map instance, including staged writes.

Source

pub fn set_attribute<T: Value>( &mut self, attribute: &Attribute<T>, value: T, ) -> HandlerResult<()>

Stages a typed Attribute write.

Source

pub fn set_attribute_map<T: Value>( &mut self, attribute: &AttributeMap<T>, instance: &str, value: T, ) -> HandlerResult<()>

Stages a typed write for one Attribute-map instance.

Source

pub fn delete_attribute<T>( &mut self, attribute: &Attribute<T>, ) -> HandlerResult<()>

Stages deletion of an Attribute value.

Source

pub fn delete_attribute_map<T>( &mut self, attribute: &AttributeMap<T>, instance: &str, ) -> HandlerResult<()>

Stages deletion of one Attribute-map instance.

Source

pub fn publish<T: Value>( &mut self, channel: &Channel<T>, value: T, ) -> HandlerResult<()>

Stages one typed Channel publication.

Source

pub fn publish_map<T: Value>( &mut self, channel: &ChannelMap<T>, instance: &str, value: T, ) -> HandlerResult<()>

Stages one typed publication to a Channel-map instance.

Source

pub fn channel_size<T>(&self, channel: &Channel<T>) -> HandlerResult<usize>

Returns the current invocation snapshot’s Channel queue size.

Source

pub fn channel_map_size<T>( &self, channel: &ChannelMap<T>, instance: &str, ) -> HandlerResult<usize>

Returns one Channel-map instance’s queue size.

Source

pub fn channel_results<T: Value>( &self, channel: &Channel<T>, ) -> HandlerResult<Vec<T>>

Decodes the messages consumed by a satisfied Channel condition.

Source

pub fn channel_map_results<T: Value>( &self, channel: &ChannelMap<T>, instance: &str, ) -> HandlerResult<Vec<T>>

Decodes messages consumed by one satisfied Channel-map condition.

Source

pub fn write_stream<T: Value>( &mut self, stream: &Stream<T>, value: T, ) -> HandlerResult<()>

Appends one immediate best-effort Stream message from a Step invocation.

§Errors

Returns HandlerError for RPC Contexts, unregistered or duplicate Streams, encoding failures, or a failed FlowService write.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> Same for T

Source§

type Output = T

Should always be Self
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, <T as TryFrom<U>>::Error>

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<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