Struct slottle::ThrottleBuilder [−][src]
Use to build a Throttle
.
Created by Throttle::builder()
API.
Implementations
impl ThrottleBuilder
[src]
pub fn interval<I>(&mut self, interval: I) -> &mut Self where
I: Into<Interval>,
[src]
I: Into<Interval>,
Set interval of throttle.
Example
use slottle::{Throttle, Interval}; use std::time::Duration; use rand; // fixed interval: 10ms Throttle::builder().interval(Duration::from_millis(10)); // random interval between: 10ms ~ 0ms Throttle::builder() .interval(|| Duration::from_millis(10).mul_f64(rand::random())); // increasing delay if failed continuously Throttle::builder() .interval(Interval::new( |log| match log.unwrap().failure_count_cont() { 0 => Duration::from_millis(10), 1 => Duration::from_millis(30), 2 => Duration::from_millis(50), 3 => Duration::from_millis(70), _ => unreachable!(), }, 3, // maximum log size )); // use pre-defined algorithm Throttle::builder() .interval(slottle::fibonacci( Duration::from_millis(10), Duration::from_secs(2), ));
pub fn concurrent(&mut self, concurrent: u32) -> &mut Self
[src]
Set concurrent, default value is 1
.
pub fn build(&self) -> Option<Throttle>
[src]
Create a new Throttle
with current configuration.
Return None
if concurrent
== 0
or larger than isize::MAX
.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for ThrottleBuilder
impl Send for ThrottleBuilder
impl Sync for ThrottleBuilder
impl Unpin for ThrottleBuilder
impl !UnwindSafe for ThrottleBuilder
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<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,