Skip to main content

execute_with_retry

Function execute_with_retry 

Source
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 reporting
  • policy - Retry policy governing backoff, jitter, and attempt limits
  • operation - The async operation to execute; receives state and config
  • state - The input state, cloned for each attempt
  • config - 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?;