Struct eventsource_client::ReconnectOptions
source · [−]pub struct ReconnectOptions { /* private fields */ }
Expand description
Configuration for a Client
’s reconnect behaviour.
let reconnect_options = ReconnectOptions::reconnect(true)
.retry_initial(false)
.delay(Duration::from_secs(1))
.backoff_factor(2)
.delay_max(Duration::from_secs(60))
.build();
See default()
for a description of the default behaviour. See
ReconnectOptionsBuilder
for descriptions of each configurable parameter.
Implementations
sourceimpl ReconnectOptions
impl ReconnectOptions
sourcepub fn reconnect(reconnect: bool) -> ReconnectOptionsBuilder
pub fn reconnect(reconnect: bool) -> ReconnectOptionsBuilder
Start building a ReconnectOptions
, by enabling or disabling
reconnection on stream error.
If reconnect
is true
(the default), the client will automatically
try to reconnect if the stream ends due to an error. If it is false
,
the client will stop receiving events after an error.
Trait Implementations
sourceimpl Clone for ReconnectOptions
impl Clone for ReconnectOptions
sourcefn clone(&self) -> ReconnectOptions
fn clone(&self) -> ReconnectOptions
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for ReconnectOptions
impl Debug for ReconnectOptions
sourceimpl Default for ReconnectOptions
impl Default for ReconnectOptions
sourcefn default() -> ReconnectOptions
fn default() -> ReconnectOptions
The default reconnect behaviour is to automatically try to reconnect if the stream ends due to an error, but not to retry if the initial connection fails.
The client will wait before each reconnect attempt, to allow time for the error condition to be resolved (e.g. for the SSE server to restart if it went down). It will wait 1 second before the first attempt, and then back off exponentially, up to a maximum wait of 1 minute.