Skip to main content

WorkflowContext

Struct WorkflowContext 

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

Holds the runtime context for a workflow execution

Implementations§

Source§

impl WorkflowContext

Source

pub fn new(workflow: &WorkflowDefinition) -> WorkflowResult<Self>

Creates a new workflow context from a workflow definition

Source

pub fn set_status(&mut self, status: StatusPhase)

Sets the overall workflow status

Source

pub fn instance_id(&self) -> &str

Gets the workflow instance ID

Source

pub fn get_status(&self) -> StatusPhase

Gets the current overall workflow status

Source

pub fn set_task_status(&mut self, task: &str, status: StatusPhase)

Sets the status for a specific task

Source

pub fn get_task_status(&self, task: &str) -> Option<StatusPhase>

Gets the current status for a specific task

Source

pub fn set_input(&mut self, value: Value)

Source

pub fn get_input(&self) -> Option<&Value>

Source

pub fn set_output(&mut self, value: Value)

Source

pub fn get_output(&self) -> Option<&Value>

Source

pub fn set_instance_ctx(&mut self, value: Value)

Source

pub fn get_instance_ctx(&self) -> Option<&Value>

Source

pub fn set_raw_input(&mut self, input: &Value)

Sets the raw input in the workflow descriptor

Source

pub fn set_task_name(&mut self, name: &str)

Sets the task name in the current task descriptor

Source

pub fn set_task_raw_input(&mut self, input: &Value)

Sets the task raw input

Source

pub fn set_task_raw_output(&mut self, output: &Value)

Sets the task raw output

Source

pub fn set_task_started_at(&mut self)

Sets the task startedAt timestamp with nested structure: { iso8601: “…”, epoch: { seconds: 123, milliseconds: 123456 } }

Source

pub fn set_task_reference(&mut self, reference: &str)

Sets the task reference (JSON Pointer)

Source

pub fn get_task_reference(&self) -> Option<&str>

Gets the task reference

Source

pub fn get_workflow_json(&self) -> Option<&Value>

Gets the serialized workflow JSON value (for json_pointer resolution)

Source

pub fn set_task_def(&mut self, task: &Value)

Gets the workflow instance ID Sets the task definition in the task descriptor

Source

pub fn inc_iteration(&mut self, position: &str) -> u32

Increments and returns the iteration counter for the given task position. Each time a task executes, this counter is incremented, starting at 1.

Source

pub fn set_retry_attempt(&mut self, attempt: u32)

Sets the retry attempt count in the task descriptor

Source

pub fn clear_task_context(&mut self)

Clears the current task context

Source

pub fn set_secret_manager(&mut self, value: Arc<dyn SecretManager>)

Source

pub fn get_secret_manager(&self) -> Option<&dyn SecretManager>

Source

pub fn clone_secret_manager(&self) -> Option<Arc<dyn SecretManager>>

Source

pub fn set_listener(&mut self, value: Arc<dyn WorkflowExecutionListener>)

Source

pub fn get_listener(&self) -> Option<&dyn WorkflowExecutionListener>

Source

pub fn clone_listener(&self) -> Option<Arc<dyn WorkflowExecutionListener>>

Source

pub fn emit_event(&self, event: WorkflowEvent)

Emits an event to the listener if configured, and publishes as CloudEvent to EventBus

Source

pub fn set_event_bus(&mut self, value: SharedEventBus)

Source

pub fn get_event_bus(&self) -> Option<&SharedEventBus>

Source

pub fn clone_event_bus(&self) -> Option<SharedEventBus>

Source

pub fn set_sub_workflows( &mut self, sub_workflows: HashMap<String, WorkflowDefinition>, )

Sets the sub-workflow registry

Source

pub fn get_sub_workflow( &self, namespace: &str, name: &str, version: &str, ) -> Option<&WorkflowDefinition>

Looks up a sub-workflow by namespace/name/version key

Source

pub fn clone_sub_workflows(&self) -> HashMap<String, WorkflowDefinition>

Clones the entire sub-workflow registry (for propagating to child runners)

Source

pub fn set_handler_registry(&mut self, registry: HandlerRegistry)

Sets the handler registry (replaces all handlers)

Source

pub fn get_handler_registry(&self) -> &HandlerRegistry

Gets a reference to the handler registry

Source

pub fn clone_handler_registry(&self) -> HandlerRegistry

Clones the handler registry (for propagating to child runners)

Source

pub fn set_functions(&mut self, functions: HashMap<String, TaskDefinition>)

Sets the registered function definitions (for call.function resolution)

Source

pub fn get_function(&self, name: &str) -> Option<&TaskDefinition>

Looks up a registered function definition by name

Source

pub fn cancellation_token(&self) -> CancellationToken

Gets a clone of the cancellation token (for use in tokio::select!)

Source

pub fn cancel(&self)

Cancels the workflow (triggers cancellation for all wait points)

Source

pub fn is_cancelled(&self) -> bool

Checks if cancellation has been requested

Source

pub fn suspend(&self) -> bool

Suspends the workflow execution

Returns true if the workflow was successfully suspended, false if it was already suspended.

Source

pub fn resume(&self) -> bool

Resumes a suspended workflow execution

Returns true if the workflow was resumed from a suspended state, false if it was not suspended.

Source

pub fn is_suspended(&self) -> bool

Checks if the workflow is currently suspended

Source

pub async fn wait_for_resume(&self)

Waits until the workflow is resumed (or cancelled)

Should be called from task runners at cooperative yield points when the workflow is detected as suspended.

Source

pub fn set_authorization(&mut self, scheme: &str, parameter: &str)

Sets the authorization descriptor for the current task Called after HTTP authentication succeeds (Basic, Bearer, Digest, OAuth2, OIDC)

Source

pub fn clear_authorization(&mut self)

Clears the authorization descriptor (called after task completes)

Source

pub fn set_local_expr_vars(&mut self, vars: HashMap<String, Value>)

Sets local expression variables (replaces all)

Source

pub fn add_local_expr_vars(&mut self, vars: HashMap<String, Value>)

Adds local expression variables (merges, does not overwrite existing keys)

Source

pub fn remove_local_expr_vars(&mut self, keys: &[&str])

Removes specified local expression variables

Source

pub fn get_vars(&self) -> HashMap<String, Value>

Returns all variables for JQ expression evaluation, using a cache to avoid rebuilding the map on every call.

Trait Implementations§

Source§

impl Clone for WorkflowContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkflowContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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