pub struct ConnectionManagerConfig { /* private fields */ }Expand description
The configuration for reconnect mechanism and request timing for the ConnectionManager
Implementations§
Source§impl ConnectionManagerConfig
impl ConnectionManagerConfig
Sourcepub fn max_delay(&self) -> Option<Duration>
pub fn max_delay(&self) -> Option<Duration>
Returns the maximum delay between connection attempts.
Sourcepub fn exponent_base(&self) -> f32
pub fn exponent_base(&self) -> f32
Returns the base used for calculating the exponential backoff between retries.
Sourcepub fn number_of_retries(&self) -> usize
pub fn number_of_retries(&self) -> usize
Returns the maximum number of connection retry attempts.
Sourcepub fn response_timeout(&self) -> Option<Duration>
pub fn response_timeout(&self) -> Option<Duration>
Returns the timeout applied to command responses.
If None, responses do not time out.
Sourcepub fn connection_timeout(&self) -> Option<Duration>
pub fn connection_timeout(&self) -> Option<Duration>
Returns the timeout applied to establishing a new connection.
If None, connection attempts to do not time out.
Sourcepub fn automatic_resubscription(&self) -> bool
pub fn automatic_resubscription(&self) -> bool
Returns true if automatic resubscription is enabled after reconnecting.
Sourcepub fn set_min_delay(self, min_delay: Duration) -> ConnectionManagerConfig
pub fn set_min_delay(self, min_delay: Duration) -> ConnectionManagerConfig
Set the minimal delay for reconnect attempts.
Sourcepub fn set_max_delay(self, time: Duration) -> ConnectionManagerConfig
pub fn set_max_delay(self, time: Duration) -> ConnectionManagerConfig
Apply a maximum delay between connection attempts. The delay between attempts won’t be longer than max_delay milliseconds.
Sourcepub fn set_exponent_base(self, base: f32) -> ConnectionManagerConfig
pub fn set_exponent_base(self, base: f32) -> ConnectionManagerConfig
The resulting duration is calculated by taking the base to the n-th power,
where n denotes the number of past attempts.
Sourcepub fn set_number_of_retries(self, amount: usize) -> ConnectionManagerConfig
pub fn set_number_of_retries(self, amount: usize) -> ConnectionManagerConfig
number_of_retries times, with an exponentially increasing delay.
Sourcepub fn set_response_timeout(
self,
duration: Option<Duration>,
) -> ConnectionManagerConfig
pub fn set_response_timeout( self, duration: Option<Duration>, ) -> ConnectionManagerConfig
The new connection will time out operations after response_timeout has passed.
Set None if you don’t want requests to time out.
Sourcepub fn set_connection_timeout(
self,
duration: Option<Duration>,
) -> ConnectionManagerConfig
pub fn set_connection_timeout( self, duration: Option<Duration>, ) -> ConnectionManagerConfig
Each connection attempt to the server will time out after connection_timeout.
Set None if you don’t want the connection attempt to time out.
Sourcepub fn set_push_sender(self, sender: impl AsyncPushSender) -> Self
pub fn set_push_sender(self, sender: impl AsyncPushSender) -> Self
Sets sender sender for push values.
The sender can be a channel, or an arbitrary function that handles crate::PushInfo values. This will fail client creation if the connection isn’t configured for RESP3 communications via the crate::RedisConnectionInfo::set_protocol function.
§Examples
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
let config = ConnectionManagerConfig::new().set_push_sender(tx);let messages = Arc::new(Mutex::new(Vec::new()));
let config = ConnectionManagerConfig::new().set_push_sender(move |msg|{
let Ok(mut messages) = messages.lock() else {
return Err(redis::aio::SendError);
};
messages.push(msg);
Ok(())
});Sourcepub fn set_automatic_resubscription(self) -> Self
pub fn set_automatic_resubscription(self) -> Self
Configures the connection manager to automatically resubscribe to all pubsub channels after reconnecting.
Trait Implementations§
Source§impl Clone for ConnectionManagerConfig
impl Clone for ConnectionManagerConfig
Source§fn clone(&self) -> ConnectionManagerConfig
fn clone(&self) -> ConnectionManagerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConnectionManagerConfig
impl Debug for ConnectionManagerConfig
Auto Trait Implementations§
impl Freeze for ConnectionManagerConfig
impl !RefUnwindSafe for ConnectionManagerConfig
impl Send for ConnectionManagerConfig
impl Sync for ConnectionManagerConfig
impl Unpin for ConnectionManagerConfig
impl !UnwindSafe for ConnectionManagerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more