Struct ConcurrentPolicy
pub struct ConcurrentPolicy<B, C> { /* private fields */ }
Expand description
A Policy
that limits the number of concurrent requests.
Implementations§
§impl<B, C> ConcurrentPolicy<B, C>
impl<B, C> ConcurrentPolicy<B, C>
pub fn with_backoff(backoff: B, tracker: C) -> ConcurrentPolicy<B, C>
pub fn with_backoff(backoff: B, tracker: C) -> ConcurrentPolicy<B, C>
Create a new ConcurrentPolicy
, using the given ConcurrentTracker
,
and the given Backoff
policy.
The Backoff
policy is used to backoff when the concurrent request limit is reached.
§impl<C> ConcurrentPolicy<(), C>
impl<C> ConcurrentPolicy<(), C>
pub const fn new(tracker: C) -> ConcurrentPolicy<(), C>
pub const fn new(tracker: C) -> ConcurrentPolicy<(), C>
Create a new ConcurrentPolicy
, using the given ConcurrentTracker
.
§impl ConcurrentPolicy<(), ConcurrentCounter>
impl ConcurrentPolicy<(), ConcurrentCounter>
pub fn max(max: usize) -> ConcurrentPolicy<(), ConcurrentCounter>
pub fn max(max: usize) -> ConcurrentPolicy<(), ConcurrentCounter>
Create a new concurrent policy,
which aborts the request if the max
limit is reached.
§impl<B> ConcurrentPolicy<B, ConcurrentCounter>
impl<B> ConcurrentPolicy<B, ConcurrentCounter>
pub fn max_with_backoff(
max: usize,
backoff: B,
) -> ConcurrentPolicy<B, ConcurrentCounter>
pub fn max_with_backoff( max: usize, backoff: B, ) -> ConcurrentPolicy<B, ConcurrentCounter>
Create a new concurrent policy, which backs off if the limit is reached, using the given backoff policy.
Trait Implementations§
§impl<B, C> Clone for ConcurrentPolicy<B, C>
impl<B, C> Clone for ConcurrentPolicy<B, C>
§fn clone(&self) -> ConcurrentPolicy<B, C>
fn clone(&self) -> ConcurrentPolicy<B, C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl<B, C> Debug for ConcurrentPolicy<B, C>
impl<B, C> Debug for ConcurrentPolicy<B, C>
§impl<B, C, Request> Policy<Request> for ConcurrentPolicy<B, C>
impl<B, C, Request> Policy<Request> for ConcurrentPolicy<B, C>
§type Guard = <C as ConcurrentTracker>::Guard
type Guard = <C as ConcurrentTracker>::Guard
The guard type that is returned when the request is allowed to proceed. Read more
§type Error = <C as ConcurrentTracker>::Error
type Error = <C as ConcurrentTracker>::Error
The error type that is returned when the request is not allowed to proceed,
and should be aborted. Read more
§async fn check(
&self,
ctx: Context,
request: Request,
) -> PolicyResult<Request, <ConcurrentPolicy<B, C> as Policy<Request>>::Guard, <ConcurrentPolicy<B, C> as Policy<Request>>::Error>
async fn check( &self, ctx: Context, request: Request, ) -> PolicyResult<Request, <ConcurrentPolicy<B, C> as Policy<Request>>::Guard, <ConcurrentPolicy<B, C> as Policy<Request>>::Error>
Check whether the request is allowed to proceed. Read more
Auto Trait Implementations§
impl<B, C> Freeze for ConcurrentPolicy<B, C>
impl<B, C> RefUnwindSafe for ConcurrentPolicy<B, C>where
C: RefUnwindSafe,
B: RefUnwindSafe,
impl<B, C> Send for ConcurrentPolicy<B, C>
impl<B, C> Sync for ConcurrentPolicy<B, C>
impl<B, C> Unpin for ConcurrentPolicy<B, C>
impl<B, C> UnwindSafe for ConcurrentPolicy<B, C>where
C: UnwindSafe,
B: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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> 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>
Create a new
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more