[][src]Struct actix_governor::GovernorConfigBuilder

pub struct GovernorConfigBuilder { /* fields omitted */ }

Helper struct for building a configuration for the governor middleware

Example

Create a configuration with a quota of ten requests per IP address that replenishes one element every minute.

use actix_governor::GovernorConfigBuilder;

let config = GovernorConfigBuilder::default()
    .per_second(60)
    .burst_size(10)
    .finish()
    .unwrap();

Implementations

impl GovernorConfigBuilder[src]

pub fn period(&mut self, duration: Duration) -> &mut Self[src]

Set the interval after which one element of the quota is replenished.

The interval must not be zero.

pub fn per_second(&mut self, seconds: u64) -> &mut Self[src]

Set the interval after which one element of the quota is replenished in seconds.

The interval must not be zero.

pub fn per_millisecond(&mut self, milliseconds: u64) -> &mut Self[src]

Set the interval after which one element of the quota is replenished in milliseconds.

The interval must not be zero.

pub fn per_nanosecond(&mut self, nanoseconds: u64) -> &mut Self[src]

Set the interval after which one element of the quota is replenished in nanoseconds.

The interval must not be zero.

pub fn burst_size(&mut self, burst_size: u32) -> &mut Self[src]

Set quota size that defines how many requests can occur before the governor middleware starts blocking requests from an IP address and clients have to wait until the elements of the quota are replenished.

The burst_size must not be zero.

pub fn finish(&mut self) -> Option<GovernorConfig>[src]

Finish building the configuration and return the configuration for the middleware. Returns None if either burst size or period interval are zero.

Trait Implementations

impl Clone for GovernorConfigBuilder[src]

impl Debug for GovernorConfigBuilder[src]

impl Default for GovernorConfigBuilder[src]

pub fn default() -> Self[src]

The default configuration which is suitable for most services. Allows burst with up to eight requests and replenishes one element after 500ms. The values can be modified by calling other methods on this struct.

impl Eq for GovernorConfigBuilder[src]

impl PartialEq<GovernorConfigBuilder> for GovernorConfigBuilder[src]

impl StructuralEq for GovernorConfigBuilder[src]

impl StructuralPartialEq for GovernorConfigBuilder[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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<V, T> VZip<V> for T where
    V: MultiLane<T>,