#[non_exhaustive]pub struct GlideClusterClientConfiguration {Show 16 fields
pub addresses: Vec<NodeAddress>,
pub tls: TlsConfig,
pub credentials: Option<ServerCredentials>,
pub read_from: ReadFrom,
pub request_timeout: Option<Duration>,
pub connection_timeout: Option<Duration>,
pub reconnect_strategy: Option<BackoffStrategy>,
pub client_name: Option<String>,
pub protocol: ProtocolVersion,
pub periodic_checks: PeriodicChecks,
pub inflight_requests_limit: Option<u32>,
pub lazy_connect: bool,
pub pubsub_subscriptions: Option<PubSubSubscriptions>,
pub force_pubsub_channel: bool,
pub root_certs: Vec<Vec<u8>>,
pub client_identity: Option<ClientIdentity>,
}Expand description
Configuration for a cluster GLIDE client.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.addresses: Vec<NodeAddress>Seed node addresses.
tls: TlsConfigTLS mode.
credentials: Option<ServerCredentials>Optional credentials.
read_from: ReadFromRead strategy.
request_timeout: Option<Duration>Overall request timeout.
connection_timeout: Option<Duration>Connection establishment timeout.
reconnect_strategy: Option<BackoffStrategy>Reconnection backoff strategy.
client_name: Option<String>Client name reported to the server.
protocol: ProtocolVersionRESP protocol version.
periodic_checks: PeriodicChecksPeriodic topology checks.
inflight_requests_limit: Option<u32>Maximum number of concurrent in-flight requests.
lazy_connect: boolDefer connecting until the first command is issued.
pubsub_subscriptions: Option<PubSubSubscriptions>Pub/Sub subscriptions to establish on connect.
force_pubsub_channel: boolForce creation of the Pub/Sub push channel even when no subscriptions are
configured, so runtime subscribe/unsubscribe can receive messages.
See crate::commands::pubsub::PubSubCommands.
root_certs: Vec<Vec<u8>>Custom CA certificate(s) (PEM bytes) to trust when verifying the server
under TlsConfig::SecureTls. Lowered into
ConnectionRequest::root_certs. Empty = use the system trust store.
client_identity: Option<ClientIdentity>Client certificate + private key for mutual TLS. Set via
Self::client_identity. Only meaningful together with
TlsConfig::SecureTls.
Implementations§
Source§impl GlideClusterClientConfiguration
impl GlideClusterClientConfiguration
Sourcepub fn with_address(host: impl Into<String>, port: u16) -> Self
pub fn with_address(host: impl Into<String>, port: u16) -> Self
Configure for a single host:port.
Sourcepub fn tls_ca_cert(self, pem: impl Into<Vec<u8>>) -> Self
pub fn tls_ca_cert(self, pem: impl Into<Vec<u8>>) -> Self
Trust a custom CA certificate (PEM bytes) when verifying the server with
TlsConfig::SecureTls. Enables secure TLS against a server presenting a
certificate signed by a private/self-signed CA. May be called more than
once to trust multiple CAs.
Sourcepub fn client_identity(
self,
cert_pem: impl Into<Vec<u8>>,
key_pem: impl Into<Vec<u8>>,
) -> Self
pub fn client_identity( self, cert_pem: impl Into<Vec<u8>>, key_pem: impl Into<Vec<u8>>, ) -> Self
Set a client certificate + private key (both PEM) for mutual TLS.
The server must be configured to require/verify client certificates.
Only meaningful together with TlsConfig::SecureTls.
Sourcepub fn credentials(self, creds: ServerCredentials) -> Self
pub fn credentials(self, creds: ServerCredentials) -> Self
Set credentials.
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
pub fn request_timeout(self, timeout: Duration) -> Self
Set request timeout.
Sourcepub fn connection_timeout(self, timeout: Duration) -> Self
pub fn connection_timeout(self, timeout: Duration) -> Self
Set the connection-establishment timeout.
Sourcepub fn inflight_requests_limit(self, limit: u32) -> Self
pub fn inflight_requests_limit(self, limit: u32) -> Self
Set the maximum number of concurrent in-flight requests.
Sourcepub fn client_name(self, name: impl Into<String>) -> Self
pub fn client_name(self, name: impl Into<String>) -> Self
Set client name.
Sourcepub fn protocol(self, protocol: ProtocolVersion) -> Self
pub fn protocol(self, protocol: ProtocolVersion) -> Self
Set protocol version.
Sourcepub fn lazy_connect(self, lazy: bool) -> Self
pub fn lazy_connect(self, lazy: bool) -> Self
Enable lazy connection.
Sourcepub fn reconnect_strategy(self, strategy: BackoffStrategy) -> Self
pub fn reconnect_strategy(self, strategy: BackoffStrategy) -> Self
Set reconnection strategy.
Sourcepub fn subscriptions(self, subscriptions: PubSubSubscriptions) -> Self
pub fn subscriptions(self, subscriptions: PubSubSubscriptions) -> Self
Set Pub/Sub subscriptions to establish on connect.
Sourcepub fn enable_pubsub(self) -> Self
pub fn enable_pubsub(self) -> Self
Enable the Pub/Sub push channel without configuring any connect-time
subscriptions, so the client can use runtime subscribe/unsubscribe
and receive messages via get_pubsub_message. Connect-time
subscriptions enable this implicitly.
Note: runtime subscriptions are session-scoped — unlike connect-time subscriptions they are not automatically restored after a reconnect.
Source§impl GlideClusterClientConfiguration
impl GlideClusterClientConfiguration
Sourcepub fn new(addresses: Vec<NodeAddress>) -> Self
pub fn new(addresses: Vec<NodeAddress>) -> Self
Create a cluster configuration for the given addresses.
Sourcepub fn from_url(url: impl AsRef<str>) -> ValkeyResult<Self>
pub fn from_url(url: impl AsRef<str>) -> ValkeyResult<Self>
Build a configuration from a connection URL.
Supports Redis URLs:
use glide::GlideClusterClientConfiguration;
let url = "redis://user:pass@localhost:6379";
let cfg = GlideClusterClientConfiguration::from_url(url).unwrap();
assert_eq!(cfg.addresses.len(), 1);rediss:// enables TLS with full verification;
rediss://…/#insecure disables certificate verification.
Does not support Unix-socket URLs (unix:// or unix+redis://).
Does not support Valkey URLs (valkey:// or valkeys://).
Sourcepub fn from_urls<S: AsRef<str>>(
urls: impl IntoIterator<Item = S>,
) -> ValkeyResult<Self>
pub fn from_urls<S: AsRef<str>>( urls: impl IntoIterator<Item = S>, ) -> ValkeyResult<Self>
Build a configuration from one or more connection URL.
Configuration must be identical across all URLs: conflicting settings are rejected with a configuration error. A URL selecting a non-zero database is also rejected because clusters only support database 0.
The RESP protocol is taken from the first URL and not cross-validated.
Supports Redis URLs:
use glide::GlideClusterClientConfiguration;
let urls = ["redis://user:pass@localhost:6379", "redis://user:pass@localhost:6380"];
let cfg = GlideClusterClientConfiguration::from_urls(urls).unwrap();
assert_eq!(cfg.addresses.len(), 2);rediss:// enables TLS with full verification;
rediss://…/#insecure disables certificate verification.
Does not support Unix-socket URLs (unix:// or unix+redis://).
Does not support Valkey URLs (valkey:// or valkeys://).
Sourcepub fn periodic_checks(self, checks: PeriodicChecks) -> Self
pub fn periodic_checks(self, checks: PeriodicChecks) -> Self
Set periodic checks.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GlideClusterClientConfiguration
impl RefUnwindSafe for GlideClusterClientConfiguration
impl Send for GlideClusterClientConfiguration
impl Sync for GlideClusterClientConfiguration
impl Unpin for GlideClusterClientConfiguration
impl UnsafeUnpin for GlideClusterClientConfiguration
impl UnwindSafe for GlideClusterClientConfiguration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request