Struct redis::aio::ConnectionManager
source · pub struct ConnectionManager { /* private fields */ }
Available on crate features
aio
and connection-manager
only.Expand description
A ConnectionManager
is a proxy that wraps a multiplexed
connection and automatically reconnects to the
server when necessary.
Like the MultiplexedConnection
, this
manager can be cloned, allowing requests to be be sent concurrently on
the same underlying connection (tcp/unix socket).
Behavior
- When creating an instance of the
ConnectionManager
, an initial connection will be established and awaited. Connection errors will be returned directly. - When a command sent to the server fails with an error that represents a “connection dropped” condition, that error will be passed on to the user, but it will trigger a reconnection in the background.
- The reconnect code will atomically swap the current (dead) connection
with a future that will eventually resolve to a
MultiplexedConnection
or to aRedisError
- All commands that are issued after the reconnect process has been initiated, will have to await the connection future.
- If reconnecting fails, all pending commands will be failed as well. A new reconnection attempt will be triggered if the error is an I/O error.
Implementations§
source§impl ConnectionManager
impl ConnectionManager
sourcepub async fn new(client: Client) -> RedisResult<Self>
pub async fn new(client: Client) -> RedisResult<Self>
Connect to the server and store the connection inside the returned ConnectionManager
.
This requires the connection-manager
feature, which will also pull in
the Tokio executor.
Trait Implementations§
source§impl Clone for ConnectionManager
impl Clone for ConnectionManager
source§fn clone(&self) -> ConnectionManager
fn clone(&self) -> ConnectionManager
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl ConnectionLike for ConnectionManager
impl ConnectionLike for ConnectionManager
source§fn req_packed_command<'a>(&'a mut self, cmd: &'a Cmd) -> RedisFuture<'a, Value>
fn req_packed_command<'a>(&'a mut self, cmd: &'a Cmd) -> RedisFuture<'a, Value>
Sends an already encoded (packed) command into the TCP socket and
reads the single response from it.
source§fn req_packed_commands<'a>(
&'a mut self,
cmd: &'a Pipeline,
offset: usize,
count: usize
) -> RedisFuture<'a, Vec<Value>>
fn req_packed_commands<'a>(
&'a mut self,
cmd: &'a Pipeline,
offset: usize,
count: usize
) -> RedisFuture<'a, Vec<Value>>
Sends multiple already encoded (packed) command into the TCP socket
and reads
count
responses from it. This is used to implement
pipelining.