Skip to main content

Module network_retry

Module network_retry 

Source
Expand description

Shared reconnection/backoff policy for networked components.

Provides NetworkRetryPolicy (config struct), retry_async (execution helper), and retry_async_cancelable (cancellation-aware variant). Components that supervise external processes (JMS, xj, xslt) should use only NetworkRetryPolicy::delay_for inside their own supervision loops.

Both retry_async and retry_async_cancelable accept an optional label for component identity in retry logs:

use camel_component_api::retry_async;

retry_async(&config.reconnect, Some("ws-producer"), op, is_retryable).await?;

When a label is set, log messages include "ws-producer: transient error — retrying" with a component structured field that operators can filter with component=ws-producer.

For location-specific context (URLs, endpoints), wrap the retry call in a tracing::span whose fields are inherited by all log events inside the retry loop:

let span = tracing::info_span!("ws_connect", url = %url);
let _guard = span.enter();
retry_async(&config.reconnect, Some("ws-producer"), op, is_retryable).await?;

Structs§

NetworkRetryPolicy
Reconnection and backoff policy for networked components.

Functions§

is_retryable_camel_error
Classify a CamelError as retryable (transient network/IO errors).
retry_async
Executes op with reconnect/backoff according to policy.
retry_async_cancelable
Like retry_async but honours a CancellationToken during inter-retry sleep.