Trait ServiceExt

Source
pub trait ServiceExt<Request>: Service<Request> {
Show 13 methods // Provided methods async fn oneshot(&self, request: Request) -> Self::Response where Self: Sized { ... } fn then<F>(self, closure: F) -> Then<Self, F> where Self: Sized { ... } fn map<F>(self, closure: F) -> Map<Self, F> where Self: Sized { ... } fn concurrency_limit(self, n_permits: usize) -> ConcurrencyLimit<Self> where Self: Sized { ... } fn load_shed(self) -> LoadShed<Self> where Self: Sized { ... } fn buffer(self, capacity: usize) -> Buffer<Self> where Self: Sized { ... } fn rate_limit(self, interval: Duration, permits: usize) -> RateLimit<Self> where Self: Sized { ... } fn retry<P>(self, policy: P) -> Retry<Self, P> where Self: Sized { ... } fn depressurize(self) -> Depressurize<Self> where Self: Sized { ... } fn pending_requests(self) -> PendingRequests<Self> where Self: Sized { ... } fn leak<'t>(self: Arc<Self>) -> Leak<'t, Self> where Self: Sized { ... } fn left<T>(self) -> Either<Self, T> where Self: Sized { ... } fn right<T>(self) -> Either<T, Self> where Self: Sized { ... }
}
Expand description

An extension trait for Service.

Provided Methods§

Source

async fn oneshot(&self, request: Request) -> Self::Response
where Self: Sized,

Acquires the Service::Permit and then immediately uses it to call the Service.

§Example
use burger::*;

let svc = service_fn(|x: usize| async move { x.to_string() });
let response = svc.oneshot(32).await;
Source

fn then<F>(self, closure: F) -> Then<Self, F>
where Self: Sized,

Extends the service using a closure accepting Self::Response and returning a Future.

See the module for more information.

Source

fn map<F>(self, closure: F) -> Map<Self, F>
where Self: Sized,

Extends the service using a closure accepting Self::Response and returning a Future.

See the module for more information.

Source

fn concurrency_limit(self, n_permits: usize) -> ConcurrencyLimit<Self>
where Self: Sized,

Applies a concurrency limit to the service with a specified number of permits.

See concurrency limit module for more information.

Source

fn load_shed(self) -> LoadShed<Self>
where Self: Sized,

Applies load shedding to the service.

See module for more information.

Source

fn buffer(self, capacity: usize) -> Buffer<Self>
where Self: Sized,

Applies buffering to the service with a specified capacity.

See the module for more information.

Source

fn rate_limit(self, interval: Duration, permits: usize) -> RateLimit<Self>
where Self: Sized,

Applies rate limiting to the service with a specified interval and number of permits.

See the module for more information.

Source

fn retry<P>(self, policy: P) -> Retry<Self, P>
where Self: Sized,

Applies retries to tbe service with a specified Policy.

See the module for more information.

Source

fn depressurize(self) -> Depressurize<Self>
where Self: Sized,

Depressurizes the service.

See the module for more information,

Source

fn pending_requests(self) -> PendingRequests<Self>
where Self: Sized,

Records Load on the service, measured by number of pending requests.

See the load module for more information.

Source

fn leak<'t>(self: Arc<Self>) -> Leak<'t, Self>
where Self: Sized,

Extends the lifetime of the permit.

See the module for more information.

Source

fn left<T>(self) -> Either<Self, T>
where Self: Sized,

Wraps as Either::Left. For the other variant see ServiceExt::right.

See the module for more information.

Source

fn right<T>(self) -> Either<T, Self>
where Self: Sized,

Wraps as Either::Right. For the other variant see ServiceExt::right.

See the module for more information.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Request, S> ServiceExt<Request> for S
where S: Service<Request>,