Skip to main content

NodeContext

Struct NodeContext 

Source
pub struct NodeContext {
    pub server: RedisServer,
    pub index: usize,
    pub port: u16,
    pub total_nodes: u16,
    pub masters: u16,
    pub replicas_per_master: u16,
}
Expand description

Context passed to the per-node configuration callback.

Provides information about the node being configured so the callback can make per-node decisions (e.g., different config for masters vs. replicas, or for a specific node index).

Fields§

§server: RedisServer

The pre-configured RedisServer builder for this node.

All uniform cluster-level settings have already been applied. The callback should modify and return this builder.

§index: usize

Zero-based index of this node in the cluster.

Nodes are ordered by port: masters occupy indices 0..masters, replicas occupy indices masters..total.

§port: u16

The port assigned to this node.

§total_nodes: u16

Total number of nodes in the cluster.

§masters: u16

Number of master nodes.

§replicas_per_master: u16

Number of replicas per master.

Implementations§

Source§

impl NodeContext

Source

pub fn is_master(&self) -> bool

Whether this node is a master (by initial topology order).

Source

pub fn is_replica(&self) -> bool

Whether this node is a replica (by initial topology order).

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

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>,

Source§

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.