pub struct ClusterClientBuilder { /* private fields */ }cluster only.Expand description
Used to configure and build a ClusterClient.
Implementations§
source§impl ClusterClientBuilder
impl ClusterClientBuilder
sourcepub fn new<T: IntoConnectionInfo>(
initial_nodes: impl IntoIterator<Item = T>,
) -> ClusterClientBuilder
pub fn new<T: IntoConnectionInfo>( initial_nodes: impl IntoIterator<Item = T>, ) -> ClusterClientBuilder
Creates a new ClusterClientBuilder with the provided initial_nodes.
This is the same as ClusterClient::builder(initial_nodes).
sourcepub fn build(self) -> RedisResult<ClusterClient>
pub fn build(self) -> RedisResult<ClusterClient>
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 tls(self, tls: TlsMode) -> ClusterClientBuilder
pub fn tls(self, tls: TlsMode) -> ClusterClientBuilder
Sets TLS mode for the new ClusterClient.
It is extracted from the first node of initial_nodes if not set.
sourcepub fn certs(self, certificates: TlsCertificates) -> ClusterClientBuilder
pub fn certs(self, certificates: TlsCertificates) -> ClusterClientBuilder
Sets raw TLS certificates for the new ClusterClient.
When set, enforces the connection must be TLS secured.
All certificates must be provided as byte streams loaded from PEM files their consistency is
checked during build() call.
certificates-TlsCertificatesstructure containing:-
client_tls- OptionalClientTlsConfigcontaining byte streams forclient_cert- client’s byte stream containing client certificate in PEM formatclient_key- client’s byte stream containing private key in PEM format
-
root_cert- Optional byte stream yielding PEM formatted file for root certificates.
-
If ClientTlsConfig ( cert+key pair ) is not provided, then client-side authentication is not enabled.
If root_cert is not provided, then system root certificates are used instead.
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) -> RedisResult<ClusterClient>
👎Deprecated since 0.22.0: Use build()
pub fn open(self) -> RedisResult<ClusterClient>
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().