pub struct Pacer { /* private fields */ }Available on crate features
polars-io and cloud only.Expand description
Lock-free hot path enforcing the rate-limit by pacing requests through the token bucket.
Implementations§
Source§impl Pacer
impl Pacer
Sourcepub fn start(bucket: Arc<TokenBucket>, max_wait: Duration) -> Arc<Pacer>
pub fn start(bucket: Arc<TokenBucket>, max_wait: Duration) -> Arc<Pacer>
Construct and spawn the wake tick. The tick is per-pacer.
Sourcepub async fn admit(&self) -> Result<(), HttpError>
pub async fn admit(&self) -> Result<(), HttpError>
Admit a request to the pacer, which may get queued internally. Returns a PacerBusy Error when the estimated wait exceeds the wait bound.
pub fn queue_depth(&self) -> u64
pub fn admitted(&self) -> u64
pub fn bucket(&self) -> &Arc<TokenBucket>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Pacer
impl RefUnwindSafe for Pacer
impl Send for Pacer
impl Sync for Pacer
impl Unpin for Pacer
impl UnsafeUnpin for Pacer
impl UnwindSafe for Pacer
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
§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