[−][src]Struct stubborn_io::ReconnectOptions
User specified options that control the behavior of the stubborn-io upon disconnect.
Fields
retries_to_attempt_fn: Box<dyn Fn() -> DurationIterator + Send + Sync>
Represents a function that generates an Iterator to schedule the wait between reconnection attempts.
exit_if_first_connect_fails: bool
If this is set to true, if the initial connect method of the stubborn-io item fails, then no further reconnects will be attempted
on_connect_callback: Box<dyn Fn() + Send + Sync>
Invoked when the StubbornIo establishes a connection
on_disconnect_callback: Box<dyn Fn() + Send + Sync>
Invoked when the StubbornIo loses its active connection
on_connect_fail_callback: Box<dyn Fn() + Send + Sync>
Invoked when the StubbornIo fails a connection attempt
Methods
impl ReconnectOptions
[src]
pub fn new() -> Self
[src]
By default, the stubborn-io will not try to reconnect if the first connect attempt fails. By default, the retries iterator waits longer and longer between reconnection attempts, until it eventually perpetually tries to reconnect every 30 minutes.
pub fn with_retries_generator<F, I, IN>(self, retries_generator: F) -> Self where
F: 'static + Send + Sync + Fn() -> IN,
I: 'static + Send + Sync + Iterator<Item = Duration>,
IN: IntoIterator<IntoIter = I, Item = Duration>,
[src]
F: 'static + Send + Sync + Fn() -> IN,
I: 'static + Send + Sync + Iterator<Item = Duration>,
IN: IntoIterator<IntoIter = I, Item = Duration>,
This convenience function allows the user to provide any function that returns a value that is convertible into an iterator, such as an actual iterator or a Vec.
Examples
use std::time::Duration; use stubborn_io::ReconnectOptions; // With the below vector, the stubborn-io item will try to reconnect three times, // waiting 2 seconds between each attempt. Once all three tries are exhausted, // it will stop attempting. let options = ReconnectOptions::new().with_retries_generator(|| { vec![ Duration::from_secs(2), Duration::from_secs(2), Duration::from_secs(2), ] });
pub fn with_exit_if_first_connect_fails(self, value: bool) -> Self
[src]
pub fn with_on_connect_callback(
self,
cb: impl Fn() + 'static + Send + Sync
) -> Self
[src]
self,
cb: impl Fn() + 'static + Send + Sync
) -> Self
pub fn with_on_disconnect_callback(
self,
cb: impl Fn() + 'static + Send + Sync
) -> Self
[src]
self,
cb: impl Fn() + 'static + Send + Sync
) -> Self
pub fn with_on_connect_fail_callback(
self,
cb: impl Fn() + 'static + Send + Sync
) -> Self
[src]
self,
cb: impl Fn() + 'static + Send + Sync
) -> Self
Auto Trait Implementations
impl Send for ReconnectOptions
impl Unpin for ReconnectOptions
impl Sync for ReconnectOptions
impl !UnwindSafe for ReconnectOptions
impl !RefUnwindSafe for ReconnectOptions
Blanket Implementations
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,