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

Fields

§server: Server

The Server identifier.

§

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

Available on crate feature unix-sockets only.

Fields

§path: PathBuf

The path to the Unix socket.

Any associated Server identifiers will use this value as the host.

§

Sentinel

Fields

§hosts: Vec<Server>

An array of Server identifiers for each known sentinel instance.

§service_name: String

The service name for primary/main instances.

§username: Option<String>
Available on crate feature sentinel-auth only.

An optional ACL username for the client to use when authenticating.

§password: Option<String>
Available on crate feature sentinel-auth only.

An optional password for the client to use when authenticating.

Implementations§

source§

impl ServerConfig

source

pub fn new_centralized<S>(host: S, port: u16) -> ServerConfig
where S: Into<String>,

Create a new centralized config with the provided host and port.

source

pub fn new_clustered<S>(hosts: Vec<(S, u16)>) -> ServerConfig
where S: Into<String>,

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.

source

pub fn new_sentinel<H, N>(hosts: Vec<(H, u16)>, service_name: N) -> ServerConfig
where H: Into<String>, N: Into<String>,

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.

source

pub fn new_unix_socket<P>(path: P) -> ServerConfig
where P: Into<PathBuf>,

Available on crate feature unix-sockets only.

Create a new server config for a connected Unix socket.

source

pub fn default_centralized() -> ServerConfig

Create a centralized config with default settings for a local deployment.

source

pub fn default_clustered() -> ServerConfig

Create a clustered config with the same defaults as specified in the create-cluster script provided by Redis.

source

pub fn is_clustered(&self) -> bool

Whether the config uses a clustered deployment.

source

pub fn is_sentinel(&self) -> bool

Whether the config is for a centralized server behind a sentinel node(s).

source

pub fn is_centralized(&self) -> bool

Whether the config is for a centralized server.

source

pub fn is_unix_socket(&self) -> bool

Whether the config uses a Unix socket.

source

pub fn hosts(&self) -> Vec<Server>

Read the server hosts or sentinel hosts if using the sentinel interface.

source

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

source§

fn clone(&self) -> ServerConfig

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ServerConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ServerConfig

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for ServerConfig

source§

fn eq(&self, other: &ServerConfig) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ServerConfig

source§

impl StructuralPartialEq for ServerConfig

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more