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§
- Network
Retry Policy - Reconnection and backoff policy for networked components.
Functions§
- is_
retryable_ camel_ error - Classify a
CamelErroras retryable (transient network/IO errors). - retry_
async - Executes
opwith reconnect/backoff according topolicy. - retry_
async_ cancelable - Like
retry_asyncbut honours aCancellationTokenduring inter-retry sleep.