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 identify the retrying component by scheme/operation in retry logs and metrics:

use camel_component_api::retry_async;

retry_async(&config.reconnect, "ws", "connect", op, is_retryable, metrics).await?;

Retry log messages include "ws/connect: transient error — retrying" with scheme and operation structured fields that operators can filter with scheme=ws operation=connect. When metrics is Some, every attempt is recorded via increment_retry_attempt(scheme, operation) and an exhausted (or non-retryable) sequence records exactly one error via increment_errors(operation, "e:{scheme}:{operation}") — call sites must NOT double-count the same exhaustion in their Err arms. Cancellation is a clean shutdown and records no error.

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, "ws", "connect", op, is_retryable, metrics).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.