Skip to main content

qubit_retry/error/
retry_error_classifier.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/// Classifies an application error as retryable or non-retryable.
14///
15/// The classifier receives the original application error and the current
16/// attempt context. Returning [`RetryDecision::Retry`] allows the executor to
17/// continue if attempt and elapsed-time limits still permit another try;
18/// returning [`RetryDecision::Abort`] stops immediately with
19/// [`crate::RetryError::Aborted`].
20///
21/// The classifier is stored as an [`ArcBiFunction`] so cloned
22/// [`crate::RetryExecutor`] instances can share it safely.
23pub type RetryErrorClassifier<E> = ArcBiFunction<E, RetryAttemptContext, RetryDecision>;