pub trait Throttle: Send + Sync {
// Required methods
fn acquire(
&self,
meta: &RequestMeta<'_>,
) -> impl Future<Output = Result<Charge, Refused>> + Send;
fn observe(
&self,
charge: &Charge,
response: &ResponseMeta<'_>,
attempt: &AttemptInfo,
);
fn hold(&self, delay: Duration);
}Expand description
Charges each attempt, sees each response, and holds every request on it.
One throttle is shared by every client that shares a budget, and its hold with it.
Required Methods§
Sourcefn acquire(
&self,
meta: &RequestMeta<'_>,
) -> impl Future<Output = Result<Charge, Refused>> + Send
fn acquire( &self, meta: &RequestMeta<'_>, ) -> impl Future<Output = Result<Charge, Refused>> + Send
Sourcefn observe(
&self,
charge: &Charge,
response: &ResponseMeta<'_>,
attempt: &AttemptInfo,
)
fn observe( &self, charge: &Charge, response: &ResponseMeta<'_>, attempt: &AttemptInfo, )
See a response to an attempt acquire charged. Runs on every
response, before the policy decides. Records counts and tiers only.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".