pub struct Retrying<P: Provider> { /* private fields */ }Expand description
A Provider wrapper that retries transient failures with exponential
backoff and full jitter, and bounds each attempt with a per-call timeout.
Scope: the retry policy applies to chat_completion only. Streaming
(chat_completion_stream) skips retry — the connection is already
established and clients consuming chunk-by-chunk handle their own
resumption — but still bounds the connection-establishment phase with
the same timeout. The non-chat methods (embedding, image_generation,
audio_speech, audio_transcription) are bare pass-throughs without
retry or timeout, because the daemon’s current protocol doesn’t expose
these endpoints. If a future daemon feature needs them, extend this
wrapper’s scope at that point.
Implementations§
Trait Implementations§
Source§impl<P: Provider> Provider for Retrying<P>
impl<P: Provider> Provider for Retrying<P>
async fn chat_completion( &self, request: &ChatCompletionRequest, ) -> Result<ChatCompletionResponse, Error>
async fn chat_completion_stream( &self, request: &ChatCompletionRequest, ) -> Result<BoxStream<'static, Result<ChatCompletionChunk, Error>>, Error>
async fn embedding( &self, request: &EmbeddingRequest, ) -> Result<EmbeddingResponse, Error>
async fn image_generation( &self, request: &ImageRequest, ) -> Result<(Bytes, String), Error>
async fn audio_speech( &self, request: &AudioSpeechRequest, ) -> Result<(Bytes, String), Error>
async fn audio_transcription( &self, model: &str, fields: &[MultipartField], ) -> Result<(Bytes, String), Error>
Auto Trait Implementations§
impl<P> Freeze for Retrying<P>where
P: Freeze,
impl<P> RefUnwindSafe for Retrying<P>where
P: RefUnwindSafe,
impl<P> Send for Retrying<P>
impl<P> Sync for Retrying<P>
impl<P> Unpin for Retrying<P>where
P: Unpin,
impl<P> UnsafeUnpin for Retrying<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for Retrying<P>where
P: UnwindSafe,
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