[−][src]Struct actix_governor::GovernorConfigBuilder
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]
pub fn clone(&self) -> GovernorConfigBuilder
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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]
pub fn eq(&self, other: &GovernorConfigBuilder) -> bool
[src]
pub fn ne(&self, other: &GovernorConfigBuilder) -> bool
[src]
impl StructuralEq for GovernorConfigBuilder
[src]
impl StructuralPartialEq for GovernorConfigBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for GovernorConfigBuilder
[src]
impl Send for GovernorConfigBuilder
[src]
impl Sync for GovernorConfigBuilder
[src]
impl Unpin for GovernorConfigBuilder
[src]
impl UnwindSafe for GovernorConfigBuilder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,