pub struct SyncWorkflowContext<W> { /* private fields */ }Expand description
Context provided to synchronous signal and update handlers.
This type provides all workflow context capabilities except state(), state_mut(),
and wait_condition(). Those methods are not applicable in sync handler contexts.
Sync handlers receive &mut self directly, so they can reference and mutate workflow state without
needing state()/state_mut().
Implementations§
Source§impl<W> SyncWorkflowContext<W>
impl<W> SyncWorkflowContext<W>
Sourcepub fn workflow_id(&self) -> &str
pub fn workflow_id(&self) -> &str
Return the workflow’s unique identifier
Sourcepub fn task_queue(&self) -> &str
pub fn task_queue(&self) -> &str
Return the task queue the workflow is executing in
Sourcepub fn workflow_time(&self) -> Option<SystemTime>
pub fn workflow_time(&self) -> Option<SystemTime>
Return the current time according to the workflow (which is not wall-clock time).
Sourcepub fn history_length(&self) -> u32
pub fn history_length(&self) -> u32
Return the length of history so far at this point in the workflow
Sourcepub fn current_deployment_version(&self) -> Option<WorkerDeploymentVersion>
pub fn current_deployment_version(&self) -> Option<WorkerDeploymentVersion>
Return the deployment version, if any, as it was when this point in the workflow was first reached. If this code is being executed for the first time, return this Worker’s deployment version if it has one.
Sourcepub fn search_attributes(&self) -> impl Deref<Target = SearchAttributes> + '_
pub fn search_attributes(&self) -> impl Deref<Target = SearchAttributes> + '_
Return current values for workflow search attributes
Sourcepub fn random_seed(&self) -> u64
pub fn random_seed(&self) -> u64
Return the workflow’s randomness seed
Sourcepub fn is_replaying(&self) -> bool
pub fn is_replaying(&self) -> bool
Returns true if the current workflow task is happening under replay
Sourcepub fn continue_as_new_suggested(&self) -> bool
pub fn continue_as_new_suggested(&self) -> bool
Returns true if the server suggests this workflow should continue-as-new
Sourcepub fn headers(&self) -> &HashMap<String, Payload>
pub fn headers(&self) -> &HashMap<String, Payload>
Returns the headers for the current handler invocation (signal, update, query, etc.).
When called from within a signal handler, returns the headers that were sent with that signal. When called from the main workflow run method, returns an empty map.
Sourcepub fn payload_converter(&self) -> &PayloadConverter
pub fn payload_converter(&self) -> &PayloadConverter
Returns the PayloadConverter currently used by the worker running this workflow.
Sourcepub fn workflow_initial_info(&self) -> &InitializeWorkflow
pub fn workflow_initial_info(&self) -> &InitializeWorkflow
Return various information that the workflow was initialized with. Will eventually become a proper non-proto workflow info struct.
Sourcepub fn cancelled(&self) -> impl FusedFuture<Output = String> + '_
pub fn cancelled(&self) -> impl FusedFuture<Output = String> + '_
A future that resolves if/when the workflow is cancelled, with the user provided cause
Sourcepub fn continue_as_new(
&self,
input: &<W::Run as WorkflowDefinition>::Input,
opts: ContinueAsNewOptions,
) -> Result<Infallible, WorkflowTermination>where
W: WorkflowImplementation,
pub fn continue_as_new(
&self,
input: &<W::Run as WorkflowDefinition>::Input,
opts: ContinueAsNewOptions,
) -> Result<Infallible, WorkflowTermination>where
W: WorkflowImplementation,
Signal that this workflow should continue as a new workflow execution with the given input and options.
This always returns an Err which should be propigated.
Sourcepub fn timer<T: Into<TimerOptions>>(
&self,
opts: T,
) -> impl CancellableFuture<TimerResult>
pub fn timer<T: Into<TimerOptions>>( &self, opts: T, ) -> impl CancellableFuture<TimerResult>
Request to create a timer
Sourcepub fn start_activity<AD: ActivityDefinition>(
&self,
activity: AD,
input: impl Into<AD::Input>,
opts: ActivityOptions,
) -> impl CancellableFuture<Result<AD::Output, ActivityExecutionError>>where
AD::Output: TemporalDeserializable,
pub fn start_activity<AD: ActivityDefinition>(
&self,
activity: AD,
input: impl Into<AD::Input>,
opts: ActivityOptions,
) -> impl CancellableFuture<Result<AD::Output, ActivityExecutionError>>where
AD::Output: TemporalDeserializable,
Request to run an activity
Sourcepub fn start_local_activity<AD: ActivityDefinition>(
&self,
activity: AD,
input: impl Into<AD::Input>,
opts: LocalActivityOptions,
) -> impl CancellableFuture<Result<AD::Output, ActivityExecutionError>>where
AD::Output: TemporalDeserializable,
pub fn start_local_activity<AD: ActivityDefinition>(
&self,
activity: AD,
input: impl Into<AD::Input>,
opts: LocalActivityOptions,
) -> impl CancellableFuture<Result<AD::Output, ActivityExecutionError>>where
AD::Output: TemporalDeserializable,
Request to run a local activity
Sourcepub fn child_workflow<WD: WorkflowDefinition>(
&self,
workflow: WD,
input: impl Into<WD::Input>,
opts: ChildWorkflowOptions,
) -> impl CancellableFutureWithReason<Result<StartedChildWorkflow<WD>, ChildWorkflowExecutionError>>where
WD::Output: TemporalDeserializable,
pub fn child_workflow<WD: WorkflowDefinition>(
&self,
workflow: WD,
input: impl Into<WD::Input>,
opts: ChildWorkflowOptions,
) -> impl CancellableFutureWithReason<Result<StartedChildWorkflow<WD>, ChildWorkflowExecutionError>>where
WD::Output: TemporalDeserializable,
Start a child workflow. Returns a future that resolves to a StartedChildWorkflow which can be used to await the result, send signals, or cancel the child.
Sourcepub fn patched(&self, patch_id: &str) -> bool
pub fn patched(&self, patch_id: &str) -> bool
Check (or record) that this workflow history was created with the provided patch
Sourcepub fn deprecate_patch(&self, patch_id: &str) -> bool
pub fn deprecate_patch(&self, patch_id: &str) -> bool
Record that this workflow history was created with the provided patch, and it is being phased out.
Sourcepub fn external_workflow(
&self,
workflow_id: impl Into<String>,
run_id: Option<String>,
) -> ExternalWorkflowHandle
pub fn external_workflow( &self, workflow_id: impl Into<String>, run_id: Option<String>, ) -> ExternalWorkflowHandle
Get a handle to an external workflow for sending signals or requesting cancellation.
Sourcepub fn upsert_search_attributes(
&self,
attr_iter: impl IntoIterator<Item = (String, Payload)>,
)
pub fn upsert_search_attributes( &self, attr_iter: impl IntoIterator<Item = (String, Payload)>, )
Add or create a set of search attributes
Sourcepub fn upsert_memo(
&self,
attr_iter: impl IntoIterator<Item = (String, Payload)>,
)
pub fn upsert_memo( &self, attr_iter: impl IntoIterator<Item = (String, Payload)>, )
Add or create a set of search attributes
Sourcepub fn set_current_details(&self, details: impl Into<String>)
pub fn set_current_details(&self, details: impl Into<String>)
Set the current details string for this workflow execution.
The value is surfaced to the Temporal server UI in real time via the the workflow metadata query.
Sourcepub fn force_task_fail(&self, with: Error)
pub fn force_task_fail(&self, with: Error)
Force a workflow task failure (EX: in order to retry on non-sticky queue)
Sourcepub fn start_nexus_operation(
&self,
opts: NexusOperationOptions,
) -> impl CancellableFuture<Result<StartedNexusOperation, Failure>>
pub fn start_nexus_operation( &self, opts: NexusOperationOptions, ) -> impl CancellableFuture<Result<StartedNexusOperation, Failure>>
Start a nexus operation
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for SyncWorkflowContext<W>
impl<W> !RefUnwindSafe for SyncWorkflowContext<W>
impl<W> !Send for SyncWorkflowContext<W>
impl<W> !Sync for SyncWorkflowContext<W>
impl<W> Unpin for SyncWorkflowContext<W>where
W: Unpin,
impl<W> UnsafeUnpin for SyncWorkflowContext<W>
impl<W> !UnwindSafe for SyncWorkflowContext<W>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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