Trait burger::Service

source ·
pub trait Service<Request> {
    type Response;
    type Permit<'a>
       where Self: 'a;

    // Required methods
    async fn acquire(&self) -> Self::Permit<'_>;
    async fn call<'a>(
        permit: Self::Permit<'a>,
        request: Request
    ) -> Self::Response
       where Self: 'a;
}
Expand description

An asynchronous function call, which can only be executed after obtaining a permit.

§Example

use burger::{service_fn::ServiceFn, *};

let svc = service_fn(|x: usize| async move { x.to_string() });
let permit = svc.acquire().await;
let response = ServiceFn::call(permit, 32).await;

Required Associated Types§

source

type Response

The type produced by the service call.

source

type Permit<'a> where Self: 'a

The type of the permit required to call the service.

Required Methods§

source

async fn acquire(&self) -> Self::Permit<'_>

Obtains a permit.

source

async fn call<'a>(permit: Self::Permit<'a>, request: Request) -> Self::Response
where Self: 'a,

Consumes a permit to call the service.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'t, Request, S> Service<Request> for &'t S
where S: Service<Request>,

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = <S as Service<Request>>::Permit<'a> where S: 'a, 't: 'a

source§

async fn acquire(&self) -> Self::Permit<'_>

source§

async fn call<'a>(permit: Self::Permit<'a>, request: Request) -> Self::Response
where Self: 'a,

source§

impl<Request, Permit, S> Service<Request> for Mutex<S>
where for<'a> S: Service<Request, Permit<'a> = Permit> + 'static,

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = Permit where S: 'a

source§

async fn acquire(&self) -> Self::Permit<'_>

source§

async fn call(permit: Self::Permit<'_>, request: Request) -> Self::Response

source§

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

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = <S as Service<Request>>::Permit<'a> where S: 'a

source§

async fn acquire(&self) -> Self::Permit<'_>

source§

async fn call(permit: Self::Permit<'_>, request: Request) -> Self::Response

source§

impl<Request, S, Permit> Service<Request> for RwLock<S>
where for<'a> S: Service<Request, Permit<'a> = Permit> + 'static,

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = <S as Service<Request>>::Permit<'a> where Self: 'a

source§

async fn acquire(&self) -> Self::Permit<'_>

source§

async fn call(permit: Self::Permit<'_>, request: Request) -> Self::Response

Implementors§

source§

impl Service<Infallible> for MiddlewareBuilder

§

type Permit<'a> = ()

§

type Response = Infallible

source§

impl<'t, Request, S> Service<Request> for Leak<'t, S>
where S: Service<Request> + 't,

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = LeakPermit<'t, S, Request> where S: 'a, 't: 'a

source§

impl<Request, A, B> Service<Request> for Either<A, B>
where A: Service<Request>, B: Service<Request, Response = A::Response>,

§

type Response = <A as Service<Request>>::Response

§

type Permit<'a> = Either<<A as Service<Request>>::Permit<'a>, <B as Service<Request>>::Permit<'a>> where Self: 'a

source§

impl<Request, Fut, F> Service<Request> for ServiceFn<F>
where F: Fn(Request) -> Fut, Fut: Future,

§

type Response = <Fut as Future>::Output

§

type Permit<'a> = &'a F where F: 'a

source§

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

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = BufferPermit<'a, S, Request> where S: 'a

source§

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

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = ConcurrencyLimitPermit<'a, S, Request> where S: 'a

source§

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

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = &'a S where S: 'a

source§

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

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = PendingRequestsPermit<'a, S, Request> where Self: 'a

source§

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

§

type Response = Result<<S as Service<Request>>::Response, Request>

§

type Permit<'a> = Option<<S as Service<Request>>::Permit<'a>> where S: 'a

source§

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

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = RateLimitPermit<'a, S, Request> where Self: 'a

source§

impl<Request, S, F, Fut> Service<Request> for Then<S, F>
where S: Service<Request>, F: Fn(S::Response) -> Fut, Fut: Future,

§

type Response = <Fut as Future>::Output

§

type Permit<'a> = ThenPermit<'a, S, F, Request> where S: 'a, F: 'a

source§

impl<Request, S, F, Output> Service<Request> for Map<S, F>
where S: Service<Request>, F: Fn(S::Response) -> Output,

§

type Response = Output

§

type Permit<'a> = MapPermit<'a, S, F, Request> where S: 'a, F: 'a

source§

impl<Request, S, I> Service<Request> for Select<S, I>
where for<'a> &'a I: IntoIterator<Item = &'a S>, S: Service<Request>,

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = <S as Service<Request>>::Permit<'a> where S: 'a, I: 'a

source§

impl<Request, S, Key> Service<Request> for Balance<S, Key>
where S: Service<Request> + Load + 'static, Key: Eq + Hash + 'static,

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = LeakPermit<'static, S, Request> where Self: 'a

source§

impl<Request, S, P> Service<Request> for Retry<S, P>
where S: Service<Request>, P: Policy<S, Request>,

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = RetryPermit<'a, S, P, Request> where Self: 'a

source§

impl<Request, S, P> Service<Request> for Steer<S, P>
where S: Service<Request>, P: Picker<S, Request>,

§

type Response = <S as Service<Request>>::Response

§

type Permit<'a> = SteerPermit<'a, S, P, Request> where Self: 'a