Struct ManagedPolicy
pub struct ManagedPolicy<B = Undefined, C = Undefined, R = Undefined, P = Undefined, S = MemoryReplay> { /* private fields */ }http and std only.Expand description
A managed retry Policy,
which allows for an easier interface to configure retrying requests.
The default MemoryReplay retains up to 64 KiB per request for up to
30 seconds. Self::with_replay_store configures a different budget or
storage backend. Self::with_prepare_body can skip capture or impose
tighter limits for individual requests.
DoNotRetry can be added to the Extensions of a Request
to signal that the request should not be retried, regardless
of the retry functionality defined.
Implementations§
§impl<F> ManagedPolicy<Undefined, Undefined, F>
impl<F> ManagedPolicy<Undefined, Undefined, F>
pub fn new(retry: F) -> ManagedPolicy<Undefined, Undefined, F>
pub fn new(retry: F) -> ManagedPolicy<Undefined, Undefined, F>
Create a new ManagedPolicy which uses the provided
function to determine if a request should be retried.
The default cloning is used and no backoff is applied.
§impl<C, R, P, S> ManagedPolicy<Undefined, C, R, P, S>
impl<C, R, P, S> ManagedPolicy<Undefined, C, R, P, S>
pub fn with_backoff<B>(self, backoff: B) -> ManagedPolicy<B, C, R, P, S>
pub fn with_backoff<B>(self, backoff: B) -> ManagedPolicy<B, C, R, P, S>
add a backoff to this ManagedPolicy.
§impl<B, R, P, S> ManagedPolicy<B, Undefined, R, P, S>
impl<B, R, P, S> ManagedPolicy<B, Undefined, R, P, S>
pub fn with_clone<C>(self, clone: C) -> ManagedPolicy<B, C, R, P, S>
pub fn with_clone<C>(self, clone: C) -> ManagedPolicy<B, C, R, P, S>
add a cloning function to this ManagedPolicy.
to determine if a request should be cloned
§impl<B, C, P, S> ManagedPolicy<B, C, Undefined, P, S>
impl<B, C, P, S> ManagedPolicy<B, C, Undefined, P, S>
pub fn with_retry<R>(self, retry: R) -> ManagedPolicy<B, C, R, P, S>
pub fn with_retry<R>(self, retry: R) -> ManagedPolicy<B, C, R, P, S>
add a retry function to this ManagedPolicy.
to determine if a request should be retried.
§impl<B, C, R, S> ManagedPolicy<B, C, R, Undefined, S>
impl<B, C, R, S> ManagedPolicy<B, C, R, Undefined, S>
pub fn with_prepare_body<P>(self, prepare: P) -> ManagedPolicy<B, C, R, P, S>
pub fn with_prepare_body<P>(self, prepare: P) -> ManagedPolicy<B, C, R, P, S>
Configure replay preparation before the body is read.
Return None to stream once, or collection options to prepare a replay.
DoNotRetry takes precedence over this function.
§impl<B, C, R, P, S> ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> ManagedPolicy<B, C, R, P, S>
pub fn with_replay_store<T>(self, store: T) -> ManagedPolicy<B, C, R, P, T>where
T: ReplayStore,
pub fn with_replay_store<T>(self, store: T) -> ManagedPolicy<B, C, R, P, T>where
T: ReplayStore,
Set the backend that captures approved bodies while the first attempt reads them.
This store is shared across requests served by this policy. A custom
backend can allocate a distinct writer for each capture in ReplayStore::start.
See the storage examples for memory and filesystem configuration.
Trait Implementations§
§impl<B, C, R, P, S> Clone for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> Clone for ManagedPolicy<B, C, R, P, S>
§fn clone(&self) -> ManagedPolicy<B, C, R, P, S>
fn clone(&self) -> ManagedPolicy<B, C, R, P, S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<B, C, R, P, S> Debug for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> Debug for ManagedPolicy<B, C, R, P, S>
§impl Default for ManagedPolicy
impl Default for ManagedPolicy
§fn default() -> ManagedPolicy
fn default() -> ManagedPolicy
§impl<B, C, R, P, S, Response, Error> Policy<Response, Error> for ManagedPolicy<B, C, R, P, S>where
B: Backoff,
P: PrepareBody,
S: ReplayStore,
C: CloneInput,
R: RetryRule<Request<RetryBody>, Response, Error>,
Response: Send + 'static,
Error: Send + 'static,
impl<B, C, R, P, S, Response, Error> Policy<Response, Error> for ManagedPolicy<B, C, R, P, S>where
B: Backoff,
P: PrepareBody,
S: ReplayStore,
C: CloneInput,
R: RetryRule<Request<RetryBody>, Response, Error>,
Response: Send + 'static,
Error: Send + 'static,
§fn prepare_body(
&self,
parts: &Parts,
is_end_stream: bool,
size_hint: &SizeHint,
) -> Option<CollectOptions>
fn prepare_body( &self, parts: &Parts, is_end_stream: bool, size_hint: &SizeHint, ) -> Option<CollectOptions>
§fn replay_store(&self, _: &Parts) -> &(dyn ReplayStore + 'static)
fn replay_store(&self, _: &Parts) -> &(dyn ReplayStore + 'static)
§async fn retry(
&self,
req: Request<RetryBody>,
result: Result<Response, Error>,
) -> PolicyResult<Response, Error>
async fn retry( &self, req: Request<RetryBody>, result: Result<Response, Error>, ) -> PolicyResult<Response, Error>
§async fn next_attempt(&self) -> bool
async fn next_attempt(&self) -> bool
Auto Trait Implementations§
impl<B, C, R, P, S> Forget for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> Freeze for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> Move for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> RefUnwindSafe for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> Send for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> Sync for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> Unpin for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> UnsafeUnpin for ManagedPolicy<B, C, R, P, S>
impl<B, C, R, P, S> UnwindSafe for ManagedPolicy<B, C, R, P, S>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more