recover_state_with_backoff

Function recover_state_with_backoff 

Source
pub async fn recover_state_with_backoff<F, T>(
    operation: F,
    max_attempts: u32,
    operation_name: &str,
) -> Result<T, CommonError>
where F: Fn() -> Result<T, CommonError> + Send,
Expand description

Attempt state recovery with exponential backoff.

§Arguments

  • operation - The operation to retry
  • max_attempts - Maximum number of retry attempts
  • operation_name - Name of the operation for logging

§Type Parameters

  • F - The operation function type
  • T - The return type of the operation

§Returns

Result containing the operation result or CommonError

§Behavior

  • Retries operation up to max_attempts times
  • Uses exponential backoff (doubles delay after each failure)
  • Starts with 100ms delay
  • Logs each attempt and failure