Struct stream_reconnect::ReconnectOptions [−][src]
pub struct ReconnectOptions(_);
Expand description
User specified options that control the behavior of the ReconnectStream upon disconnect.
Implementations
By default, the ReconnectStream 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.
Represents a function that generates an Iterator to schedule the wait between reconnection attempts. This method allows the user to provide any function that returns a value which is convertible into an iterator, such as an actual iterator or a Vec.
Examples
use std::time::Duration;
use stream_reconnect::ReconnectOptions;
// With the below vector, the ReconnectStream 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),
]
});
If this is set to true, if the initial connect method of the ReconnectStream item fails, then no further reconnects will be attempted
Invoked when the ReconnectStream establishes a connection
Invoked when the ReconnectStream loses its active connection
Invoked when the ReconnectStream fails a connection attempt
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for ReconnectOptions
impl Send for ReconnectOptions
impl Sync for ReconnectOptions
impl Unpin for ReconnectOptions
impl !UnwindSafe for ReconnectOptions
Blanket Implementations
Mutably borrows from an owned value. Read more