pub struct WfContext { /* private fields */ }Expand description
Used within workflows to issue commands, get info, etc.
Implementations§
Source§impl WfContext
impl WfContext
Sourcepub fn task_queue(&self) -> &str
pub fn task_queue(&self) -> &str
Return the task queue the workflow is executing in
Sourcepub fn get_args(&self) -> &[Payload]
pub fn get_args(&self) -> &[Payload]
Get the arguments provided to the workflow upon execution start
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 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 async fn cancelled(&self) -> String
pub async fn cancelled(&self) -> String
A future that resolves if/when the workflow is cancelled, with the user provided cause
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 activity(
&self,
opts: ActivityOptions,
) -> impl CancellableFuture<ActivityResolution>
pub fn activity( &self, opts: ActivityOptions, ) -> impl CancellableFuture<ActivityResolution>
Request to run an activity
Sourcepub fn local_activity(
&self,
opts: LocalActivityOptions,
) -> impl CancellableFuture<ActivityResolution> + '_
pub fn local_activity( &self, opts: LocalActivityOptions, ) -> impl CancellableFuture<ActivityResolution> + '_
Request to run a local activity
Sourcepub fn child_workflow(&self, opts: ChildWorkflowOptions) -> ChildWorkflow
pub fn child_workflow(&self, opts: ChildWorkflowOptions) -> ChildWorkflow
Creates a child workflow stub with the provided options
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 signal_workflow(
&self,
opts: impl Into<SignalWorkflowOptions>,
) -> impl CancellableFuture<SignalExternalWfResult>
pub fn signal_workflow( &self, opts: impl Into<SignalWorkflowOptions>, ) -> impl CancellableFuture<SignalExternalWfResult>
Send a signal to an external workflow. May resolve as a failure if the signal didn’t work or was cancelled.
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 make_signal_channel(
&self,
signal_name: impl Into<String>,
) -> DrainableSignalStream
pub fn make_signal_channel( &self, signal_name: impl Into<String>, ) -> DrainableSignalStream
Return a stream that produces values when the named signal is sent to this workflow
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 cancel_external(
&self,
target: NamespacedWorkflowExecution,
reason: String,
) -> impl Future<Output = CancelExternalWfResult>
pub fn cancel_external( &self, target: NamespacedWorkflowExecution, reason: String, ) -> impl Future<Output = CancelExternalWfResult>
Request the cancellation of an external workflow. May resolve as a failure if the workflow was not found or the cancel was otherwise unsendable.
Sourcepub fn update_handler<Arg, Res>(
&self,
name: impl Into<String>,
validator: impl IntoUpdateValidatorFunc<Arg>,
handler: impl IntoUpdateHandlerFunc<Arg, Res>,
)
pub fn update_handler<Arg, Res>( &self, name: impl Into<String>, validator: impl IntoUpdateValidatorFunc<Arg>, handler: impl IntoUpdateHandlerFunc<Arg, Res>, )
Register an update handler by providing the handler name, a validator function, and an update handler. The validator must not mutate workflow state and is synchronous. The handler may mutate workflow state (though, that’s annoying right now in the prototype) and is async.
Note that if you want a validator that always passes, you will likely need to provide type
annotations to make the compiler happy, like: |_: &_, _: T| Ok(())
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 Freeze for WfContext
impl !RefUnwindSafe for WfContext
impl Send for WfContext
impl Sync for WfContext
impl Unpin for WfContext
impl !UnwindSafe for WfContext
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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