pub async fn execute_with_retry<E: RedisCommandExecutor>(
executor: &mut E,
cmd: &RedisCommand,
exchange: &mut Exchange,
is_idempotent: bool,
policy: &NetworkRetryPolicy,
) -> Result<(), CamelError>Expand description
Executes a command with retry on transient errors, using NetworkRetryPolicy.
This is the core retry logic extracted for testability.
policy: reconnection policy (max attempts, backoff, jitter, etc.)is_idempotent: whether the command is safe to retry
§Implementation note
Uses a manual retry loop calling NetworkRetryPolicy::should_retry and
NetworkRetryPolicy::delay_for rather than the shared [retry_async]
helper. Manual loop needed because: (a) executor.reconnect() must run
before each retry attempt (not the first attempt), so retry_async’s
“always invoke op” model doesn’t fit; (b) &mut executor / &mut exchange
borrows cannot be re-borrowed through FnMut() -> async move { ... } —
the Future returned by the closure holds the borrow past the closure body,
which the borrow checker rejects. retry_async_cancelable has the same
FnMut constraint so it is also excluded.