pub struct RetryProvider {
pub max_retries: u32,
pub base_delay: Duration,
/* private fields */
}Expand description
Opt-in retry wrapper for any LlmProvider.
Wraps an inner provider and retries transient errors (timeout, network,
HTTP 500/429) up to max_retries times with exponential backoff starting
from base_delay. Non-retryable errors (auth, process, nested session,
other HTTP status codes) are returned immediately.
Implements LlmProvider itself, making it transparent to consumers.
Fields§
§max_retries: u32Maximum number of retry attempts after the first failure.
base_delay: DurationDelay between retry attempts.
Implementations§
Source§impl RetryProvider
impl RetryProvider
Sourcepub fn new(inner: Arc<dyn LlmProvider>) -> Self
pub fn new(inner: Arc<dyn LlmProvider>) -> Self
Creates a new RetryProvider with default settings (3 retries, 1s delay).
§Parameters
inner: The provider to wrap with retry logic.
Sourcepub fn with_config(
inner: Arc<dyn LlmProvider>,
max_retries: u32,
base_delay: Duration,
) -> Self
pub fn with_config( inner: Arc<dyn LlmProvider>, max_retries: u32, base_delay: Duration, ) -> Self
Creates a new RetryProvider with custom retry settings.
§Parameters
inner: The provider to wrap with retry logic.max_retries: Maximum retry attempts after the initial failure.base_delay: Initial delay between retries; doubles on each subsequent attempt.
Trait Implementations§
Source§impl LlmProvider for RetryProvider
impl LlmProvider for RetryProvider
Source§fn complete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
system_prompt: &'life1 str,
user_prompt: &'life2 str,
config: &'life3 CompletionConfig,
) -> Pin<Box<dyn Future<Output = Result<String, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn complete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
system_prompt: &'life1 str,
user_prompt: &'life2 str,
config: &'life3 CompletionConfig,
) -> Pin<Box<dyn Future<Output = Result<String, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Sends a completion request to the LLM provider. Read more
Auto Trait Implementations§
impl Freeze for RetryProvider
impl !RefUnwindSafe for RetryProvider
impl Send for RetryProvider
impl Sync for RetryProvider
impl Unpin for RetryProvider
impl UnsafeUnpin for RetryProvider
impl !UnwindSafe for RetryProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more