pub async fn execute_with_timeout(
node: &dyn Node,
ctx: &NodeContext,
policy: &TimeoutPolicy,
) -> Result<NodeOutput>Expand description
Execute a node with timeout enforcement.
Uses tokio::select! to race node execution against configured timeouts.
When a timeout fires, the configured OnTimeout recovery action is applied:
OnTimeout::Fail: ReturnsGraphError::NodeTimedOut.OnTimeout::Retry: Re-executes the node up tomax_attemptstimes.OnTimeout::Skip: Returns an emptyNodeOutput.
A tracing::warn! is emitted whenever a timeout triggers a recovery action.
§Arguments
node- The node to execute.ctx- The node execution context.policy- The timeout policy to enforce.
§Example
ⓘ
use adk_graph::timeout::{execute_with_timeout, TimeoutPolicy, OnTimeout};
use std::time::Duration;
let policy = TimeoutPolicy {
run_timeout: Some(Duration::from_secs(5)),
idle_timeout: None,
on_timeout: OnTimeout::Fail,
};
let result = execute_with_timeout(&my_node, &ctx, &policy).await;