pub struct WorkflowContext { /* private fields */ }Expand description
Holds the runtime context for a workflow execution
Implementations§
Source§impl WorkflowContext
impl WorkflowContext
Sourcepub fn new(workflow: &WorkflowDefinition) -> WorkflowResult<Self>
pub fn new(workflow: &WorkflowDefinition) -> WorkflowResult<Self>
Creates a new workflow context from a workflow definition
Sourcepub fn set_status(&mut self, status: StatusPhase)
pub fn set_status(&mut self, status: StatusPhase)
Sets the overall workflow status
Sourcepub fn instance_id(&self) -> &str
pub fn instance_id(&self) -> &str
Gets the workflow instance ID
Sourcepub fn get_status(&self) -> StatusPhase
pub fn get_status(&self) -> StatusPhase
Gets the current overall workflow status
Sourcepub fn set_task_status(&mut self, task: &str, status: StatusPhase)
pub fn set_task_status(&mut self, task: &str, status: StatusPhase)
Sets the status for a specific task
Sourcepub fn get_task_status(&self, task: &str) -> Option<StatusPhase>
pub fn get_task_status(&self, task: &str) -> Option<StatusPhase>
Gets the current status for a specific task
pub fn set_input(&mut self, value: Value)
pub fn get_input(&self) -> Option<&Value>
pub fn set_output(&mut self, value: Value)
pub fn get_output(&self) -> Option<&Value>
pub fn set_instance_ctx(&mut self, value: Value)
pub fn get_instance_ctx(&self) -> Option<&Value>
Sourcepub fn set_raw_input(&mut self, input: &Value)
pub fn set_raw_input(&mut self, input: &Value)
Sets the raw input in the workflow descriptor
Sourcepub fn set_task_name(&mut self, name: &str)
pub fn set_task_name(&mut self, name: &str)
Sets the task name in the current task descriptor
Sourcepub fn set_task_raw_input(&mut self, input: &Value)
pub fn set_task_raw_input(&mut self, input: &Value)
Sets the task raw input
Sourcepub fn set_task_raw_output(&mut self, output: &Value)
pub fn set_task_raw_output(&mut self, output: &Value)
Sets the task raw output
Sourcepub fn set_task_started_at(&mut self)
pub fn set_task_started_at(&mut self)
Sets the task startedAt timestamp with nested structure: { iso8601: “…”, epoch: { seconds: 123, milliseconds: 123456 } }
Sourcepub fn set_task_reference(&mut self, reference: &str)
pub fn set_task_reference(&mut self, reference: &str)
Sets the task reference (JSON Pointer)
Sourcepub fn get_task_reference(&self) -> Option<&str>
pub fn get_task_reference(&self) -> Option<&str>
Gets the task reference
Sourcepub fn get_workflow_json(&self) -> Option<&Value>
pub fn get_workflow_json(&self) -> Option<&Value>
Gets the serialized workflow JSON value (for json_pointer resolution)
Sourcepub fn set_task_def(&mut self, task: &Value)
pub fn set_task_def(&mut self, task: &Value)
Gets the workflow instance ID Sets the task definition in the task descriptor
Sourcepub fn inc_iteration(&mut self, position: &str) -> u32
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.
Sourcepub fn set_retry_attempt(&mut self, attempt: u32)
pub fn set_retry_attempt(&mut self, attempt: u32)
Sets the retry attempt count in the task descriptor
Sourcepub fn clear_task_context(&mut self)
pub fn clear_task_context(&mut self)
Clears the current task context
pub fn set_secret_manager(&mut self, value: Arc<dyn SecretManager>)
pub fn get_secret_manager(&self) -> Option<&dyn SecretManager>
pub fn clone_secret_manager(&self) -> Option<Arc<dyn SecretManager>>
pub fn set_listener(&mut self, value: Arc<dyn WorkflowExecutionListener>)
pub fn get_listener(&self) -> Option<&dyn WorkflowExecutionListener>
pub fn clone_listener(&self) -> Option<Arc<dyn WorkflowExecutionListener>>
Sourcepub fn emit_event(&self, event: WorkflowEvent)
pub fn emit_event(&self, event: WorkflowEvent)
Emits an event to the listener if configured, and publishes as CloudEvent to EventBus
pub fn set_event_bus(&mut self, value: SharedEventBus)
pub fn get_event_bus(&self) -> Option<&SharedEventBus>
pub fn clone_event_bus(&self) -> Option<SharedEventBus>
Sourcepub fn set_sub_workflows(
&mut self,
sub_workflows: HashMap<String, WorkflowDefinition>,
)
pub fn set_sub_workflows( &mut self, sub_workflows: HashMap<String, WorkflowDefinition>, )
Sets the sub-workflow registry
Sourcepub fn get_sub_workflow(
&self,
namespace: &str,
name: &str,
version: &str,
) -> Option<&WorkflowDefinition>
pub fn get_sub_workflow( &self, namespace: &str, name: &str, version: &str, ) -> Option<&WorkflowDefinition>
Looks up a sub-workflow by namespace/name/version key
Sourcepub fn clone_sub_workflows(&self) -> HashMap<String, WorkflowDefinition>
pub fn clone_sub_workflows(&self) -> HashMap<String, WorkflowDefinition>
Clones the entire sub-workflow registry (for propagating to child runners)
Sourcepub fn set_handler_registry(&mut self, registry: HandlerRegistry)
pub fn set_handler_registry(&mut self, registry: HandlerRegistry)
Sets the handler registry (replaces all handlers)
Sourcepub fn get_handler_registry(&self) -> &HandlerRegistry
pub fn get_handler_registry(&self) -> &HandlerRegistry
Gets a reference to the handler registry
Sourcepub fn clone_handler_registry(&self) -> HandlerRegistry
pub fn clone_handler_registry(&self) -> HandlerRegistry
Clones the handler registry (for propagating to child runners)
Sourcepub fn set_functions(&mut self, functions: HashMap<String, TaskDefinition>)
pub fn set_functions(&mut self, functions: HashMap<String, TaskDefinition>)
Sets the registered function definitions (for call.function resolution)
Sourcepub fn get_function(&self, name: &str) -> Option<&TaskDefinition>
pub fn get_function(&self, name: &str) -> Option<&TaskDefinition>
Looks up a registered function definition by name
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Gets a clone of the cancellation token (for use in tokio::select!)
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Checks if cancellation has been requested
Sourcepub fn suspend(&self) -> bool
pub fn suspend(&self) -> bool
Suspends the workflow execution
Returns true if the workflow was successfully suspended,
false if it was already suspended.
Sourcepub fn resume(&self) -> bool
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.
Sourcepub fn is_suspended(&self) -> bool
pub fn is_suspended(&self) -> bool
Checks if the workflow is currently suspended
Sourcepub async fn wait_for_resume(&self)
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.
Sets the authorization descriptor for the current task Called after HTTP authentication succeeds (Basic, Bearer, Digest, OAuth2, OIDC)
Clears the authorization descriptor (called after task completes)
Sourcepub fn set_local_expr_vars(&mut self, vars: HashMap<String, Value>)
pub fn set_local_expr_vars(&mut self, vars: HashMap<String, Value>)
Sets local expression variables (replaces all)
Sourcepub fn add_local_expr_vars(&mut self, vars: HashMap<String, Value>)
pub fn add_local_expr_vars(&mut self, vars: HashMap<String, Value>)
Adds local expression variables (merges, does not overwrite existing keys)
Sourcepub fn remove_local_expr_vars(&mut self, keys: &[&str])
pub fn remove_local_expr_vars(&mut self, keys: &[&str])
Removes specified local expression variables