pub trait WorkflowExecutor: Send + Sync {
// Required methods
fn has_workflow(&self, workflow_id: &str) -> bool;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: WorkflowState,
cancel_token: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn execute_durable<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: WorkflowState,
run: WorkflowRunContext,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Executes a registered workflow for a background run.
A background run names a target; something has to turn that into work. Implement
this to bridge to whatever executes workflows in your application — adk-graph, the
functional API, or your own dispatcher.
§Errors
Return Err to fail the attempt. A failed attempt is retried while the run has
attempts left, so surface real failures rather than encoding them as Ok.
Required Methods§
Sourcefn has_workflow(&self, workflow_id: &str) -> bool
fn has_workflow(&self, workflow_id: &str) -> bool
Whether workflow_id can be executed.
Checked before a run is queued, so an unknown workflow is rejected instead of being accepted and then failed.
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: WorkflowState,
cancel_token: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: WorkflowState,
cancel_token: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run workflow_id with input.
cancel_token fires when the run is cancelled; implementations should observe it
and stop.
Provided Methods§
Sourcefn execute_durable<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: WorkflowState,
run: WorkflowRunContext,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_durable<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: WorkflowState,
run: WorkflowRunContext,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run workflow_id as one attempt of a durable run.
run carries the run’s identity, its checkpoint thread, whether this attempt
resumes a stopped one, and the cancellation token. A graph workflow passes
run.thread_id to its executor so a resumed attempt continues from its
checkpointer, and may report checkpoints with
WorkflowRunContext::record_checkpoint. The default calls
execute, which restarts the workflow from its input.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".