pub trait RunHandler: Send + Sync {
// Required methods
fn run_type(&self) -> &str;
fn handle<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
task_name: &'life1 str,
run_config: &'life2 Value,
input: &'life3 Value,
) -> Pin<Box<dyn Future<Output = WorkflowResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
}Expand description
Handler for run task types that require custom implementations.
Implement this trait to provide support for run types like container and script.
Register handlers with WorkflowRunner::with_run_handler().
§Example
use async_trait::async_trait;
use serde_json::Value;
use swf_runtime::{RunHandler, WorkflowResult};
struct ContainerRunHandler;
#[async_trait]
impl RunHandler for ContainerRunHandler {
fn run_type(&self) -> &str { "container" }
async fn handle(
&self,
task_name: &str,
run_config: &Value,
input: &Value,
) -> WorkflowResult<Value> {
// Implement container run logic here
Ok(serde_json::json!({ "exitCode": 0 }))
}
}Required Methods§
Sourcefn run_type(&self) -> &str
fn run_type(&self) -> &str
Returns the run type this handler supports (e.g., “container”, “script”)
Sourcefn handle<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
task_name: &'life1 str,
run_config: &'life2 Value,
input: &'life3 Value,
) -> Pin<Box<dyn Future<Output = WorkflowResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
task_name: &'life1 str,
run_config: &'life2 Value,
input: &'life3 Value,
) -> Pin<Box<dyn Future<Output = WorkflowResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Executes the run with the given configuration and input.