[][src]Struct interledger_service_util::RateLimitService

pub struct RateLimitService<S, I, A> { /* fields omitted */ }

Rate Limit Service

Incoming Service responsible for rejecting requests by users who have reached their account's rate limit. Talks with the associated Store in order to figure out and set the rate limits per account. This service does packet based limiting and amount based limiting.

Forwards everything else. Requires a RateLimitAccount and a RateLimitStore. It is an IncomingService.

Methods

impl<S, I, A> RateLimitService<S, I, A> where
    S: AddressStore + RateLimitStore<Account = A> + Clone + Send + Sync,
    I: IncomingService<A> + Clone + Send + Sync,
    A: RateLimitAccount + Sync
[src]

pub fn new(store: S, next: I) -> Self[src]

Trait Implementations

impl<S: Clone, I: Clone, A: Clone> Clone for RateLimitService<S, I, A>[src]

impl<S, I, A> IncomingService<A> for RateLimitService<S, I, A> where
    S: AddressStore + RateLimitStore<Account = A> + Clone + Send + Sync + 'static,
    I: IncomingService<A> + Clone + Send + Sync + 'static,
    A: RateLimitAccount + Sync + 'static, 
[src]

type Future = BoxedIlpFuture

fn handle_request(&mut self, request: IncomingRequest<A>) -> Self::Future[src]

On receiving a request:

  1. Apply rate limit based on the sender of the request and the amount in the prepare packet in the request
  2. If no limits were hit forward the request
    • If it succeeds, OK
    • If the request forwarding failed, the client should not be charged towards their throughput limit, so they are refunded, and return a reject
  3. If the limit was hit, return a reject with the appropriate ErrorCode.

Auto Trait Implementations

impl<S, I, A> Send for RateLimitService<S, I, A> where
    A: Send,
    I: Send,
    S: Send

impl<S, I, A> Sync for RateLimitService<S, I, A> where
    A: Sync,
    I: Sync,
    S: Sync

impl<S, I, A> Unpin for RateLimitService<S, I, A> where
    A: Unpin,
    I: Unpin,
    S: Unpin

impl<S, I, A> UnwindSafe for RateLimitService<S, I, A> where
    A: UnwindSafe,
    I: UnwindSafe,
    S: UnwindSafe

impl<S, I, A> RefUnwindSafe for RateLimitService<S, I, A> where
    A: RefUnwindSafe,
    I: RefUnwindSafe,
    S: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err