qubit_retry/error/retry_decider.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026.
4 * Haixing Hu, Qubit Co. Ltd.
5 *
6 * All rights reserved.
7 *
8 ******************************************************************************/
9
10use crate::event::{RetryAttemptContext, RetryDecision};
11use qubit_function::ArcBiFunction;
12
13/// Decides whether to perform another retry after a failed attempt.
14///
15/// The executor calls this with the application **error** `E` and a
16/// [`RetryAttemptContext`] snapshot; implementors inspect that error (and
17/// context) and return [`RetryDecision::Retry`] to try again or
18/// [`RetryDecision::Abort`] to stop immediately with [`crate::RetryError::Aborted`],
19/// subject to attempt and elapsed-time limits.
20///
21/// Stored as an [`ArcBiFunction`] so cloned [`crate::RetryExecutor`] instances can
22/// share the same logic safely.
23pub type RetryDecider<E> = ArcBiFunction<E, RetryAttemptContext, RetryDecision>;