pub struct ClusterNode {
pub id: NodeId,
pub addr: SocketAddr,
pub cluster_bus_addr: SocketAddr,
pub role: NodeRole,
pub slots: Vec<SlotRange>,
pub replicates: Option<NodeId>,
pub replicas: Vec<NodeId>,
pub last_seen: Instant,
pub last_ping_sent: Option<Instant>,
pub last_pong_received: Option<Instant>,
pub flags: NodeFlags,
pub config_epoch: u64,
}Expand description
Information about a single node in the cluster.
Fields§
§id: NodeIdUnique node identifier.
addr: SocketAddrAddress for client connections.
cluster_bus_addr: SocketAddrAddress for cluster bus (gossip) connections. Typically addr.port + 10000.
role: NodeRoleNode’s role in the cluster.
slots: Vec<SlotRange>Slot ranges assigned to this node (only for primaries).
replicates: Option<NodeId>If this is a replica, the ID of its primary.
replicas: Vec<NodeId>IDs of nodes replicating this one (if primary).
last_seen: InstantLast time we received a message from this node.
last_ping_sent: Option<Instant>Last time we sent a ping to this node.
last_pong_received: Option<Instant>Last time we received a pong from this node.
flags: NodeFlagsStatus flags.
config_epoch: u64Configuration epoch (used for conflict resolution).
Implementations§
Source§impl ClusterNode
impl ClusterNode
Sourcepub fn new_primary(id: NodeId, addr: SocketAddr) -> Self
pub fn new_primary(id: NodeId, addr: SocketAddr) -> Self
Creates a new primary node with the default bus port offset (10000).
Sourcepub fn new_primary_with_offset(
id: NodeId,
addr: SocketAddr,
bus_port_offset: u16,
) -> Self
pub fn new_primary_with_offset( id: NodeId, addr: SocketAddr, bus_port_offset: u16, ) -> Self
Creates a new primary node with a custom bus port offset.
Sourcepub fn new_replica(id: NodeId, addr: SocketAddr, primary_id: NodeId) -> Self
pub fn new_replica(id: NodeId, addr: SocketAddr, primary_id: NodeId) -> Self
Creates a new replica node.
Sourcepub fn set_myself(&mut self)
pub fn set_myself(&mut self)
Marks this node as the local node.
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Returns true if this node is healthy and can serve requests.
Sourcepub fn slot_count(&self) -> u16
pub fn slot_count(&self) -> u16
Returns the total number of slots owned by this node.
Sourcepub fn to_cluster_nodes_line(&self, slot_map: &SlotMap) -> String
pub fn to_cluster_nodes_line(&self, slot_map: &SlotMap) -> String
Formats the node in CLUSTER NODES output format.
Trait Implementations§
Source§impl Clone for ClusterNode
impl Clone for ClusterNode
Source§fn clone(&self) -> ClusterNode
fn clone(&self) -> ClusterNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more