pub async fn execute_with_retry<S, F, Fut>(
node_name: &str,
policy: &RetryPolicy,
operation: F,
state: &S,
config: &RunnableConfig,
) -> Result<Command<S>, JunctureError>where
S: State,
F: Fn(&S, &RunnableConfig) -> Fut,
Fut: Future<Output = Result<Command<S>, JunctureError>>,Expand description
Execute an async operation with retry according to the given policy.
Implements exponential backoff with optional jitter, configurable max interval
capping, and a predicate-based retry filter. When retry_on is None, all
errors except cancellation and interrupt are retried.
§Arguments
node_name- Name of the node for error reportingpolicy- Retry policy governing backoff, jitter, and attempt limitsoperation- The async operation to execute; receives state and configstate- The input state, cloned for each attemptconfig- Execution configuration passed through to the operation
§Errors
Returns the last error when all attempts are exhausted, or immediately
returns if the error is not retryable (per retry_on predicate or default
cancellation/interrupt filter).
§Examples
ⓘ
use juncture_core::graph::builder::{RetryPolicy, execute_with_retry};
let policy = RetryPolicy::default();
let result = execute_with_retry(
"my_node",
&policy,
|state, config| my_node.call(state, config),
state,
&config,
).await?;