Struct redis::aio::ConnectionManager
source · [−]pub struct ConnectionManager { /* private fields */ }
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
sourceimpl 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
sourceimpl Clone for ConnectionManager
impl Clone for ConnectionManager
sourcefn clone(&self) -> ConnectionManager
fn clone(&self) -> ConnectionManager
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl ConnectionLike for ConnectionManager
impl ConnectionLike for ConnectionManager
sourcefn 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. Read more
sourcefn 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. Read more
Auto Trait Implementations
impl !RefUnwindSafe for ConnectionManager
impl Send for ConnectionManager
impl Sync for ConnectionManager
impl Unpin for ConnectionManager
impl !UnwindSafe for ConnectionManager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more