pub struct LlmFailoverBuilder { /* private fields */ }Expand description
Builder for provider failover/retry scenarios
(mirrors org.mockserver.client.LlmFailoverBuilder).
Produces an ordered list of expectations: failure expectations (limited
times) first, then a single success expectation with unlimited times.
Consecutive identical failures are coalesced into one expectation with
times.remainingTimes = count.
Implementations§
Source§impl LlmFailoverBuilder
impl LlmFailoverBuilder
Sourcepub fn with_provider(self, provider: impl Into<String>) -> Self
pub fn with_provider(self, provider: impl Into<String>) -> Self
Set the LLM provider (use a Provider constant).
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Set the model name.
Sourcepub fn fail_with(self, status_code: u16) -> Self
pub fn fail_with(self, status_code: u16) -> Self
Add a single failure with the default error body for status_code.
§Panics
Panics if status_code is outside 100..=599.
Sourcepub fn fail_with_body(
self,
status_code: u16,
error_body: impl Into<String>,
) -> Self
pub fn fail_with_body( self, status_code: u16, error_body: impl Into<String>, ) -> Self
Sourcepub fn fail_with_count(self, status_code: u16, count: u32) -> Self
pub fn fail_with_count(self, status_code: u16, count: u32) -> Self
Add count consecutive failures with the default error body.
§Panics
Panics if status_code is outside 100..=599 or count < 1.
Sourcepub fn then_respond_with(self, completion: Completion) -> Self
pub fn then_respond_with(self, completion: Completion) -> Self
Set the success completion served after all failures are consumed.
Sourcepub fn failure_count(&self) -> usize
pub fn failure_count(&self) -> usize
Number of failure attempts configured.
Sourcepub fn apply_to(&self, client: &MockServerClient) -> Result<Value>
pub fn apply_to(&self, client: &MockServerClient) -> Result<Value>
Build and register the expectations on the given client.
Trait Implementations§
Source§impl Clone for LlmFailoverBuilder
impl Clone for LlmFailoverBuilder
Source§fn clone(&self) -> LlmFailoverBuilder
fn clone(&self) -> LlmFailoverBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more