Struct deadpool_redis::cluster::ClusterClientBuilder
source · pub struct ClusterClientBuilder { /* private fields */ }
Expand description
Used to configure and build a ClusterClient
.
Implementations§
source§impl ClusterClientBuilder
impl ClusterClientBuilder
sourcepub fn new<T>(
initial_nodes: impl IntoIterator<Item = T>,
) -> ClusterClientBuilderwhere
T: IntoConnectionInfo,
pub fn new<T>(
initial_nodes: impl IntoIterator<Item = T>,
) -> ClusterClientBuilderwhere
T: IntoConnectionInfo,
Creates a new ClusterClientBuilder
with the provided initial_nodes.
This is the same as ClusterClient::builder(initial_nodes)
.
sourcepub fn build(self) -> Result<ClusterClient, RedisError>
pub fn build(self) -> Result<ClusterClient, RedisError>
Creates a new ClusterClient
from the parameters.
This does not create connections to the Redis Cluster, but only performs some basic checks on the initial nodes’ URLs and passwords/usernames.
When the tls-rustls
feature is enabled and TLS credentials are provided, they are set for
each cluster connection.
§Errors
Upon failure to parse initial nodes or if the initial nodes have different passwords or usernames, an error is returned.
sourcepub fn password(self, password: String) -> ClusterClientBuilder
pub fn password(self, password: String) -> ClusterClientBuilder
Sets password for the new ClusterClient.
sourcepub fn username(self, username: String) -> ClusterClientBuilder
pub fn username(self, username: String) -> ClusterClientBuilder
Sets username for the new ClusterClient.
sourcepub fn retries(self, retries: u32) -> ClusterClientBuilder
pub fn retries(self, retries: u32) -> ClusterClientBuilder
Sets number of retries for the new ClusterClient.
sourcepub fn max_retry_wait(self, max_wait: u64) -> ClusterClientBuilder
pub fn max_retry_wait(self, max_wait: u64) -> ClusterClientBuilder
Sets maximal wait time in millisceonds between retries for the new ClusterClient.
sourcepub fn min_retry_wait(self, min_wait: u64) -> ClusterClientBuilder
pub fn min_retry_wait(self, min_wait: u64) -> ClusterClientBuilder
Sets minimal wait time in millisceonds between retries for the new ClusterClient.
sourcepub fn retry_wait_formula(
self,
factor: u64,
exponent_base: u64,
) -> ClusterClientBuilder
pub fn retry_wait_formula( self, factor: u64, exponent_base: u64, ) -> ClusterClientBuilder
Sets the factor and exponent base for the retry wait time. The formula for the wait is rand(min_wait_retry .. min(max_retry_wait , factor * exponent_base ^ retry))ms.
sourcepub fn read_from_replicas(self) -> ClusterClientBuilder
pub fn read_from_replicas(self) -> ClusterClientBuilder
Enables reading from replicas for all new connections (default is disabled).
If enabled, then read queries will go to the replica nodes & write queries will go to the primary nodes. If there are no replica nodes, then all queries will go to the primary nodes.
sourcepub fn connection_timeout(
self,
connection_timeout: Duration,
) -> ClusterClientBuilder
pub fn connection_timeout( self, connection_timeout: Duration, ) -> ClusterClientBuilder
Enables timing out on slow connection time.
If enabled, the cluster will only wait the given time on each connection attempt to each node.
sourcepub fn response_timeout(
self,
response_timeout: Duration,
) -> ClusterClientBuilder
pub fn response_timeout( self, response_timeout: Duration, ) -> ClusterClientBuilder
Enables timing out on slow responses.
If enabled, the cluster will only wait the given time to each response from each node.
sourcepub fn use_protocol(self, protocol: ProtocolVersion) -> ClusterClientBuilder
pub fn use_protocol(self, protocol: ProtocolVersion) -> ClusterClientBuilder
Sets the protocol with which the client should communicate with the server.
sourcepub fn open(self) -> Result<ClusterClient, RedisError>
👎Deprecated since 0.22.0: Use build()
pub fn open(self) -> Result<ClusterClient, RedisError>
Use build()
.
sourcepub fn readonly(self, read_from_replicas: bool) -> ClusterClientBuilder
👎Deprecated since 0.22.0: Use read_from_replicas()
pub fn readonly(self, read_from_replicas: bool) -> ClusterClientBuilder
Use read_from_replicas()
.