Struct slottle::ThrottlePoolBuilder [−][src]
Use to build a ThrottlePool
.
Created by ThrottlePool::builder()
API.
Implementations
impl<K: Hash + Eq> ThrottlePoolBuilder<K>
[src]
pub fn interval<I>(&mut self, interval: I) -> &mut Self where
I: Into<Interval>,
[src]
I: Into<Interval>,
Set interval of throttles in this pool.
The default value is no delay (Duration::new(0, 0)
)
Example
use slottle::{ThrottlePool, Interval}; use std::time::Duration; use rand; // fixed interval: 10ms let pool: ThrottlePool<bool> = ThrottlePool::builder() .interval(Duration::from_millis(10)) .build().unwrap(); // random interval between: 10ms ~ 0ms let pool: ThrottlePool<bool> = ThrottlePool::builder() .interval(|| Duration::from_millis(10).mul_f64(rand::random())) .build().unwrap(); // increasing delay if failed continuously let pool: ThrottlePool<bool> = ThrottlePool::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 )) .build().unwrap(); // use pre-defined interval algorithm let pool: ThrottlePool<bool> = ThrottlePool::builder() .interval(slottle::fibonacci( Duration::from_millis(10), Duration::from_secs(2), )) .build().unwrap();
pub fn concurrent(&mut self, concurrent: u32) -> &mut Self
[src]
Set concurrent, default value is 1
.
pub fn build(&self) -> Option<ThrottlePool<K>>
[src]
Create a new ThrottlePool
with current configuration.
Return None
if concurrent
== 0
or larger than isize::MAX
.
Trait Implementations
impl<K: Hash + Eq> Debug for ThrottlePoolBuilder<K>
[src]
impl<K: Hash + Eq> Default for ThrottlePoolBuilder<K>
[src]
Auto Trait Implementations
impl<K> !RefUnwindSafe for ThrottlePoolBuilder<K>
impl<K> Send for ThrottlePoolBuilder<K> where
K: Send,
K: Send,
impl<K> Sync for ThrottlePoolBuilder<K> where
K: Sync,
K: Sync,
impl<K> Unpin for ThrottlePoolBuilder<K> where
K: Unpin,
K: Unpin,
impl<K> !UnwindSafe for ThrottlePoolBuilder<K>
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>,