Enum fred::types::ServerConfig
source · pub enum ServerConfig {
Centralized {
server: Server,
},
Clustered {
hosts: Vec<Server>,
policy: ClusterDiscoveryPolicy,
},
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: ClusterDiscoveryPolicyThe cluster discovery policy to use when connecting or following redirections.
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 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
impl Eq for ServerConfig
impl StructuralPartialEq for ServerConfig
Auto Trait Implementations§
impl !Freeze for ServerConfig
impl RefUnwindSafe for ServerConfig
impl Send for ServerConfig
impl Sync for ServerConfig
impl Unpin for ServerConfig
impl UnwindSafe for ServerConfig
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<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 more