pub struct SimpleRetryPolicy { /* private fields */ }Available on crate features
middleware and _api only.Expand description
Simple tower::retry::Policy for OpenAI compatible APIs.
SimpleRetryPolicy retries rate limits, server errors, and native connect
errors. It can be used directly with tower::ServiceBuilder::retry
around crate::middleware::ReqwestService or any compatible tower service
whose request type is crate::middleware::HttpRequestFactory.
The default policy allows three retry attempts.
Implementations§
Source§impl SimpleRetryPolicy
impl SimpleRetryPolicy
Sourcepub fn new(max_retries: usize) -> Self
pub fn new(max_retries: usize) -> Self
Create a policy that allows at most max_retries retry attempts.
This value is the number of additional attempts after the initial request, not the total number of requests.
Sourcepub fn max_retries(&self) -> usize
pub fn max_retries(&self) -> usize
Number of retry attempts configured for this policy.
Trait Implementations§
Source§impl Clone for SimpleRetryPolicy
impl Clone for SimpleRetryPolicy
Source§fn clone(&self) -> SimpleRetryPolicy
fn clone(&self) -> SimpleRetryPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SimpleRetryPolicy
impl Debug for SimpleRetryPolicy
Source§impl Default for SimpleRetryPolicy
impl Default for SimpleRetryPolicy
Source§impl Policy<HttpRequestFactory, Response, OpenAIError> for SimpleRetryPolicy
impl Policy<HttpRequestFactory, Response, OpenAIError> for SimpleRetryPolicy
Source§type Future = Pin<Box<dyn Future<Output = ()> + Send>>
type Future = Pin<Box<dyn Future<Output = ()> + Send>>
The
Future type returned by Policy::retry.Source§fn retry(
&mut self,
_req: &mut HttpRequestFactory,
result: &mut Result<Response, OpenAIError>,
) -> Option<Self::Future>
fn retry( &mut self, _req: &mut HttpRequestFactory, result: &mut Result<Response, OpenAIError>, ) -> Option<Self::Future>
Check the policy if a certain request should be retried. Read more
Source§fn clone_request(
&mut self,
req: &HttpRequestFactory,
) -> Option<HttpRequestFactory>
fn clone_request( &mut self, req: &HttpRequestFactory, ) -> Option<HttpRequestFactory>
Tries to clone a request before being passed to the inner service. Read more
Auto Trait Implementations§
impl Freeze for SimpleRetryPolicy
impl RefUnwindSafe for SimpleRetryPolicy
impl Send for SimpleRetryPolicy
impl Sync for SimpleRetryPolicy
impl Unpin for SimpleRetryPolicy
impl UnsafeUnpin for SimpleRetryPolicy
impl UnwindSafe for SimpleRetryPolicy
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