Skip to main content

execute_with_timeout

Function execute_with_timeout 

Source
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:

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;