pub struct SocketBuilder<I, O> { /* private fields */ }
Expand description
Builder for Socket
Uses the DEFAULT_* consts for backoff and retry config
Implementations§
Source§impl<I, O> SocketBuilder<I, O>
impl<I, O> SocketBuilder<I, O>
Sourcepub fn new(url: String) -> Self
pub fn new(url: String) -> Self
Create a new builder from the given url with other config set to defaults
Sourcepub fn set_backoff_min(self, backoff_min: Duration) -> Self
pub fn set_backoff_min(self, backoff_min: Duration) -> Self
Update the minimum backoff duration (must be > 0 millis)
Sourcepub fn set_backoff_max(self, backoff_max: Option<Duration>) -> Self
pub fn set_backoff_max(self, backoff_max: Option<Duration>) -> Self
Update the maximum backoff duration (if set must be < u32::MAX millis)
Sourcepub fn set_max_retries(self, max_retries: u32) -> Self
pub fn set_max_retries(self, max_retries: u32) -> Self
Update the maximum number of retry attempts
Sourcepub fn set_stable_timeout(self, stable_timeout: Duration) -> Self
pub fn set_stable_timeout(self, stable_timeout: Duration) -> Self
Update the stable timeout. Must be <= u32::MAX millis
This determines how long a connection needs to stay open after a retry before it is considered stable and the retry counter is reset to 0
Sourcepub fn open(self) -> Result<Socket<I, O>, Error<I, O>>
pub fn open(self) -> Result<Socket<I, O>, Error<I, O>>
Attempts to create a reconnecting websocket and do the initial open
It’s set up to error at this poing because the kind of errors that can occur here are likely
fatal (See gloo::net::websocket::futures::WebSocket::open
for details). These could
be panics but the consumer may want to display the error to the user or fallback to
plain http