Skip to main content

Cluster

Struct Cluster 

Source
pub struct Cluster { /* private fields */ }
Expand description

A distributed cluster of nodes.

Implementations§

Source§

impl Cluster

Source

pub fn new(local_node: NodeInfo, config: ClusterConfig) -> Self

Create a new cluster.

Source

pub fn id(&self) -> &str

Get the cluster ID.

Source

pub fn config(&self) -> &ClusterConfig

Get the cluster configuration.

Source

pub fn state(&self) -> ClusterState

Get the current cluster state.

Source

pub fn set_state(&self, state: ClusterState)

Set the cluster state.

Source

pub fn local_node_id(&self) -> &NodeId

Get the local node ID.

Source

pub fn leader_id(&self) -> Option<NodeId>

Get the current leader ID.

Source

pub fn set_leader(&self, leader_id: Option<NodeId>)

Set the leader ID.

Source

pub fn is_leader(&self) -> bool

Check if this node is the leader.

Source

pub fn add_node(&self, node: NodeInfo) -> Result<(), ClusterError>

Add a node to the cluster.

Source

pub fn remove_node(&self, node_id: &NodeId) -> Result<NodeInfo, ClusterError>

Remove a node from the cluster.

Source

pub fn get_node(&self, node_id: &NodeId) -> Option<NodeInfo>

Get a node by ID.

Source

pub fn nodes(&self) -> Vec<NodeInfo>

Get all nodes in the cluster.

Source

pub fn node_ids(&self) -> Vec<NodeId>

Get all node IDs.

Source

pub fn node_count(&self) -> usize

Get the number of nodes.

Source

pub fn peers(&self) -> Vec<NodeInfo>

Get peer nodes (excluding local).

Source

pub fn peer_ids(&self) -> Vec<NodeId>

Get peer IDs.

Source

pub fn update_health(&self, health: NodeHealth)

Update node health.

Source

pub fn get_health(&self, node_id: &NodeId) -> Option<NodeHealth>

Get health for a node.

Source

pub fn heartbeat(&self, node_id: &NodeId)

Process heartbeat from a node.

Source

pub fn check_failures(&self) -> Vec<NodeId>

Check for failed nodes based on timeout.

Source

pub fn has_quorum(&self) -> bool

Check if cluster has quorum.

Source

pub fn stats(&self) -> ClusterStats

Get cluster statistics.

Source

pub fn voting_members(&self) -> Vec<NodeId>

Get nodes that can vote.

Source

pub fn set_node_role(&self, node_id: &NodeId, role: NodeRole)

Update node role.

Source

pub fn leader(&self) -> Option<NodeInfo>

Get the current leader node.

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