Skip to main content

task_with_retry

Function task_with_retry 

Source
pub fn task_with_retry<M, F>(
    policy: RetryPolicy,
    f: F,
    on_exhaust: fn(String) -> M,
) -> Cmd<M>
where M: Send + 'static, F: Fn() -> Result<M, String> + Send + 'static,
Expand description

Create a Cmd::Task that retries on failure with the given policy.

The f closure returns Result<M, String>. On Ok, the message is returned immediately. On Err, the task retries according to the policy, sleeping between attempts. After all retries are exhausted, on_exhaust is called with the last error to produce a fallback message.