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
impl Context
Sourcepub fn flow_started_at(&self) -> SystemTime
pub fn flow_started_at(&self) -> SystemTime
Returns when the current Flow run started.
Sourcepub fn step_execution_id(&self) -> &str
pub fn step_execution_id(&self) -> &str
Returns the current Step execution ID, or an empty string for an RPC.
Sourcepub fn from_step_execution_id(&self) -> &str
pub fn from_step_execution_id(&self) -> &str
Returns the predecessor Step execution ID, or an empty string when absent.
Sourcepub fn first_attempt_at(&self) -> SystemTime
pub fn first_attempt_at(&self) -> SystemTime
Returns when the first attempt of this handler invocation started.
Sourcepub fn has_any_timer_fired(&self) -> bool
pub fn has_any_timer_fired(&self) -> bool
Returns whether any timer condition completed for this execute invocation.
Sourcepub fn has_timer_fired(&self, index: usize) -> bool
pub fn has_timer_fired(&self, index: usize) -> bool
Returns whether the zero-based timer at index completed.
Missing indexes return false.
Sourcepub fn wait_for_method_failed(&self) -> bool
pub fn wait_for_method_failed(&self) -> bool
Returns whether execute is running because wait_for exhausted retries with Proceed.
Sourcepub fn wait_for_cancellation(&self)
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.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns immediately with the current handler-cancellation state.
Sourcepub fn set_step_execution_local<T: Value>(
&mut self,
key: &str,
value: T,
) -> HandlerResult<()>
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.
Sourcepub fn step_execution_local<T: Value>(&self, key: &str) -> HandlerResult<T>
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.
Sourcepub fn record_event<T: Value>(
&mut self,
name: &str,
value: T,
) -> HandlerResult<()>
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.
Sourcepub fn get_attribute<T: Value>(
&self,
attribute: &Attribute<T>,
) -> HandlerResult<Option<T>>
pub fn get_attribute<T: Value>( &self, attribute: &Attribute<T>, ) -> HandlerResult<Option<T>>
Reads an Attribute value, including writes staged by this invocation.
Sourcepub fn get_attribute_map<T: Value>(
&self,
attribute: &AttributeMap<T>,
instance: &str,
) -> HandlerResult<Option<T>>
pub fn get_attribute_map<T: Value>( &self, attribute: &AttributeMap<T>, instance: &str, ) -> HandlerResult<Option<T>>
Reads one Attribute-map instance, including staged writes.
Sourcepub fn set_attribute<T: Value>(
&mut self,
attribute: &Attribute<T>,
value: T,
) -> HandlerResult<()>
pub fn set_attribute<T: Value>( &mut self, attribute: &Attribute<T>, value: T, ) -> HandlerResult<()>
Stages a typed Attribute write.
Sourcepub fn set_attribute_map<T: Value>(
&mut self,
attribute: &AttributeMap<T>,
instance: &str,
value: T,
) -> HandlerResult<()>
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.
Sourcepub fn delete_attribute<T>(
&mut self,
attribute: &Attribute<T>,
) -> HandlerResult<()>
pub fn delete_attribute<T>( &mut self, attribute: &Attribute<T>, ) -> HandlerResult<()>
Stages deletion of an Attribute value.
Sourcepub fn delete_attribute_map<T>(
&mut self,
attribute: &AttributeMap<T>,
instance: &str,
) -> HandlerResult<()>
pub fn delete_attribute_map<T>( &mut self, attribute: &AttributeMap<T>, instance: &str, ) -> HandlerResult<()>
Stages deletion of one Attribute-map instance.
Sourcepub fn publish<T: Value>(
&mut self,
channel: &Channel<T>,
value: T,
) -> HandlerResult<()>
pub fn publish<T: Value>( &mut self, channel: &Channel<T>, value: T, ) -> HandlerResult<()>
Stages one typed Channel publication.
Sourcepub fn publish_map<T: Value>(
&mut self,
channel: &ChannelMap<T>,
instance: &str,
value: T,
) -> HandlerResult<()>
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.
Sourcepub fn channel_size<T>(&self, channel: &Channel<T>) -> HandlerResult<usize>
pub fn channel_size<T>(&self, channel: &Channel<T>) -> HandlerResult<usize>
Returns the current invocation snapshot’s Channel queue size.
Sourcepub fn channel_map_size<T>(
&self,
channel: &ChannelMap<T>,
instance: &str,
) -> HandlerResult<usize>
pub fn channel_map_size<T>( &self, channel: &ChannelMap<T>, instance: &str, ) -> HandlerResult<usize>
Returns one Channel-map instance’s queue size.
Sourcepub fn channel_results<T: Value>(
&self,
channel: &Channel<T>,
) -> HandlerResult<Vec<T>>
pub fn channel_results<T: Value>( &self, channel: &Channel<T>, ) -> HandlerResult<Vec<T>>
Decodes the messages consumed by a satisfied Channel condition.
Sourcepub fn channel_map_results<T: Value>(
&self,
channel: &ChannelMap<T>,
instance: &str,
) -> HandlerResult<Vec<T>>
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.
Sourcepub fn write_stream<T: Value>(
&mut self,
stream: &Stream<T>,
value: T,
) -> HandlerResult<()>
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§
impl !Freeze for Context
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
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> 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