pub struct Failover { /* private fields */ }Expand description
Tries the primary, and on a transient exhaustion tries each fallback in order — turn-local, so the next call starts from the primary again.
Two rules carry the design:
- Only errors carrying a
retry::ProviderErrorin their chain are eligible, and only transient ones. The providers attach that marker exactly when nothing of the attempt was consumed — a mid-stream failure has already shown the user deltas, and re-issuing it would replay half an answer.Invalid/ContextOverflowfail identically everywhere, andAuth/Billingare the primary’s problem, not a routing decision. - Each fallback answers as itself. The request’s model name is
rewritten to the fallback’s own default — sending one server’s model
name to another server was a real recorded bug (
mecha replay -p).
Implementations§
Trait Implementations§
Source§impl Provider for Failover
impl Provider for Failover
Source§fn default_model(&self) -> &str
fn default_model(&self) -> &str
Model used when the caller doesn’t name one.
Source§fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 CompletionRequest,
sink: Option<&'life2 StreamSink>,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 CompletionRequest,
sink: Option<&'life2 StreamSink>,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run one turn. With
sink, stream and emit deltas as they arrive; the
accumulated response is still returned.Auto Trait Implementations§
impl !RefUnwindSafe for Failover
impl !UnwindSafe for Failover
impl Freeze for Failover
impl Send for Failover
impl Sync for Failover
impl Unpin for Failover
impl UnsafeUnpin for Failover
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