Enum fred::types::ServerConfig
source · pub enum ServerConfig {
Centralized {
server: Server,
},
Clustered {
hosts: Vec<Server>,
policy: ClusterDiscoveryPolicy,
},
Unix {
path: PathBuf,
},
Sentinel {
hosts: Vec<Server>,
service_name: String,
username: Option<String>,
password: Option<String>,
},
}
Expand description
Connection configuration for the Redis server.
Variants§
Centralized
Clustered
Fields
hosts: Vec<Server>
The known cluster node Server
identifiers.
Only one node in the cluster needs to be provided here, the rest will be discovered via the CLUSTER SLOTS
command.
policy: ClusterDiscoveryPolicy
The cluster discovery policy to use when connecting or following redirections.
Unix
unix-sockets
only.Fields
Sentinel
Implementations§
source§impl ServerConfig
impl ServerConfig
sourcepub fn new_centralized<S>(host: S, port: u16) -> ServerConfig
pub fn new_centralized<S>(host: S, port: u16) -> ServerConfig
Create a new centralized config with the provided host and port.
sourcepub fn new_clustered<S>(hosts: Vec<(S, u16)>) -> ServerConfig
pub fn new_clustered<S>(hosts: Vec<(S, u16)>) -> ServerConfig
Create a new clustered config with the provided set of hosts and ports.
Only one valid host in the cluster needs to be provided here. The client will use CLUSTER NODES
to discover
the other nodes.
sourcepub fn new_sentinel<H, N>(hosts: Vec<(H, u16)>, service_name: N) -> ServerConfig
pub fn new_sentinel<H, N>(hosts: Vec<(H, u16)>, service_name: N) -> ServerConfig
Create a new sentinel config with the provided set of hosts and the name of the service.
This library will connect using the details from the Redis documentation.
sourcepub fn new_unix_socket<P>(path: P) -> ServerConfig
Available on crate feature unix-sockets
only.
pub fn new_unix_socket<P>(path: P) -> ServerConfig
unix-sockets
only.Create a new server config for a connected Unix socket.
sourcepub fn default_centralized() -> ServerConfig
pub fn default_centralized() -> ServerConfig
Create a centralized config with default settings for a local deployment.
sourcepub fn default_clustered() -> ServerConfig
pub fn default_clustered() -> ServerConfig
Create a clustered config with the same defaults as specified in the create-cluster
script provided by Redis.
sourcepub fn is_clustered(&self) -> bool
pub fn is_clustered(&self) -> bool
Whether the config uses a clustered deployment.
sourcepub fn is_sentinel(&self) -> bool
pub fn is_sentinel(&self) -> bool
Whether the config is for a centralized server behind a sentinel node(s).
sourcepub fn is_centralized(&self) -> bool
pub fn is_centralized(&self) -> bool
Whether the config is for a centralized server.
sourcepub fn is_unix_socket(&self) -> bool
pub fn is_unix_socket(&self) -> bool
Whether the config uses a Unix socket.
sourcepub fn hosts(&self) -> Vec<Server>
pub fn hosts(&self) -> Vec<Server>
Read the server hosts or sentinel hosts if using the sentinel interface.
sourcepub fn set_cluster_discovery_policy(
&mut self,
new_policy: ClusterDiscoveryPolicy
) -> Result<(), RedisError>
pub fn set_cluster_discovery_policy( &mut self, new_policy: ClusterDiscoveryPolicy ) -> Result<(), RedisError>
Set the ClusterDiscoveryPolicy, if possible.
Trait Implementations§
source§impl Clone for ServerConfig
impl Clone for ServerConfig
source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ServerConfig
impl Debug for ServerConfig
source§impl Default for ServerConfig
impl Default for ServerConfig
source§impl PartialEq for ServerConfig
impl PartialEq for ServerConfig
source§fn eq(&self, other: &ServerConfig) -> bool
fn eq(&self, other: &ServerConfig) -> bool
self
and other
values to be equal, and is used
by ==
.