pub struct ClusterState { /* private fields */ }Expand description
Cluster state with thread-safe metrics collection
Implementations§
Source§impl ClusterState
impl ClusterState
Sourcepub fn circuit_breaker_for(&self, node_id: &str) -> CircuitBreaker
pub fn circuit_breaker_for(&self, node_id: &str) -> CircuitBreaker
Gets (creating with default config on first use) the circuit breaker
tracking TCP transport failures for one node. The returned handle is
a cheap Arc-backed clone sharing state with every other caller for
the same node_id — recording a failure through one clone is visible
to all of them.
Sourcepub fn register(&self, node: NodeResources)
pub fn register(&self, node: NodeResources)
Register a new node with the cluster
Sourcepub fn register_with_addr(&self, node: NodeResources, addr: Option<SocketAddr>)
pub fn register_with_addr(&self, node: NodeResources, addr: Option<SocketAddr>)
Register a new node with a specific socket address
Sourcepub fn nodes(&self) -> Vec<NodeResources>
pub fn nodes(&self) -> Vec<NodeResources>
Get all nodes
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get total number of registered nodes.
Sourcepub fn nodes_snapshot(&self) -> Arc<Vec<NodeResources>> ⓘ
pub fn nodes_snapshot(&self) -> Arc<Vec<NodeResources>> ⓘ
Get a shared snapshot of all nodes
Sourcepub fn with_metrics<F, R>(&self, f: F) -> R
pub fn with_metrics<F, R>(&self, f: F) -> R
Execute a closure with a read lock on the metrics map, avoiding clones and multiple acquisitions.
Sourcepub fn get_metrics(&self, node_id: &str) -> Option<NodeMetrics>
pub fn get_metrics(&self, node_id: &str) -> Option<NodeMetrics>
Get metrics for a specific node
Sourcepub fn update_heartbeat(&self, node_id: &str)
pub fn update_heartbeat(&self, node_id: &str)
Update last heartbeat for a node
Sourcepub fn get_metrics_mut<F, R>(&self, node_id: &str, f: F) -> Option<R>where
F: FnOnce(&mut NodeMetrics) -> R,
pub fn get_metrics_mut<F, R>(&self, node_id: &str, f: F) -> Option<R>where
F: FnOnce(&mut NodeMetrics) -> R,
Get metrics mutable reference (for internal updates)
Sourcepub fn check_heartbeat_timeout(&self, node_id: &str) -> bool
pub fn check_heartbeat_timeout(&self, node_id: &str) -> bool
Check if a node has timed out
Sourcepub fn mark_failed(&self, node_id: &str)
pub fn mark_failed(&self, node_id: &str)
Mark a node as failed due to timeout
Sourcepub fn recover_node(&self, node_id: &str)
pub fn recover_node(&self, node_id: &str)
Recover a failed node
Sourcepub fn active_nodes(&self) -> Vec<NodeMetrics>
pub fn active_nodes(&self) -> Vec<NodeMetrics>
Get all active nodes
Sourcepub fn active_nodes_count(&self) -> usize
pub fn active_nodes_count(&self) -> usize
Get the count of active nodes without cloning metrics
Sourcepub fn total_vram_gb(&self) -> f32
pub fn total_vram_gb(&self) -> f32
Get total cluster VRAM
Sourcepub fn total_system_memory_gb(&self) -> f32
pub fn total_system_memory_gb(&self) -> f32
Get total system memory
Trait Implementations§
Source§impl Clone for ClusterState
impl Clone for ClusterState
Source§impl Debug for ClusterState
impl Debug for ClusterState
Auto Trait Implementations§
impl Freeze for ClusterState
impl RefUnwindSafe for ClusterState
impl Send for ClusterState
impl Sync for ClusterState
impl Unpin for ClusterState
impl UnsafeUnpin for ClusterState
impl UnwindSafe for ClusterState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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