Struct redis::sentinel::SentinelClient
source · pub struct SentinelClient { /* private fields */ }
Expand description
An alternative to the Client type which creates connections from clients created
on-demand based on information fetched from the sentinels. Uses the Sentinel type
internally. This is basic an utility to help make it easier to use sentinels but
with an interface similar to the client (get_connection
and
get_async_connection
). The type of server (master or replica) and name of the
desired master are specified when constructing an instance, so it will always
return connections to the same target (for example, always to the master with name
“mymaster123”, or always to replicas of the master “another-master-abc”).
Implementations§
source§impl SentinelClient
impl SentinelClient
sourcepub fn build<T: IntoConnectionInfo>(
params: Vec<T>,
service_name: String,
node_connection_info: Option<SentinelNodeConnectionInfo>,
server_type: SentinelServerType
) -> RedisResult<Self>
pub fn build<T: IntoConnectionInfo>( params: Vec<T>, service_name: String, node_connection_info: Option<SentinelNodeConnectionInfo>, server_type: SentinelServerType ) -> RedisResult<Self>
Creates a SentinelClient performing some basic checks on the URLs that might result in an error.
sourcepub fn get_connection(&mut self) -> RedisResult<Connection>
pub fn get_connection(&mut self) -> RedisResult<Connection>
Creates a new connection to the desired type of server (based on the service/master name, and the server type). We use a Sentinel to create a client for the target type of server, and then create a connection using that client.
source§impl SentinelClient
impl SentinelClient
To enable async support you need to chose one of the supported runtimes and active its
corresponding feature: tokio-comp
or async-std-comp
sourcepub async fn get_async_connection(&mut self) -> RedisResult<AsyncConnection>
Available on crate feature aio
only.
pub async fn get_async_connection(&mut self) -> RedisResult<AsyncConnection>
aio
only.Returns an async connection from the client, using the same logic from
SentinelClient::get_connection
.