pub struct WorkerRegistry { /* private fields */ }Expand description
The worker registry — tracks all known workers and their status.
Implementations§
Source§impl WorkerRegistry
impl WorkerRegistry
pub fn new() -> Self
pub fn with_heartbeat_timeout(self, secs: i64) -> Self
Sourcepub fn register(
&self,
id: impl Into<String>,
address: impl Into<String>,
capabilities: Capabilities,
)
pub fn register( &self, id: impl Into<String>, address: impl Into<String>, capabilities: Capabilities, )
Register a new worker or update an existing one.
Sourcepub fn heartbeat(&self, worker_id: &str, load: LoadMetrics)
pub fn heartbeat(&self, worker_id: &str, load: LoadMetrics)
Update a worker’s heartbeat and load metrics.
Sourcepub fn disconnect(&self, worker_id: &str)
pub fn disconnect(&self, worker_id: &str)
Mark a worker as disconnected.
Sourcepub fn active_workers(&self) -> Vec<WorkerStatus>
pub fn active_workers(&self) -> Vec<WorkerStatus>
Get all alive, connected workers.
Sourcepub fn get(&self, worker_id: &str) -> Option<WorkerStatus>
pub fn get(&self, worker_id: &str) -> Option<WorkerStatus>
Get a specific worker by ID.
Sourcepub fn find_workers(
&self,
tags: &[String],
max_concurrent: usize,
) -> Vec<WorkerStatus>
pub fn find_workers( &self, tags: &[String], max_concurrent: usize, ) -> Vec<WorkerStatus>
Find workers matching required tags with available capacity.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Total number of registered workers (including disconnected).
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of alive, connected workers.
Sourcepub fn prune_stale(&self)
pub fn prune_stale(&self)
Prune workers that haven’t sent a heartbeat within the timeout.
Trait Implementations§
Source§impl Clone for WorkerRegistry
impl Clone for WorkerRegistry
Source§fn clone(&self) -> WorkerRegistry
fn clone(&self) -> WorkerRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WorkerRegistry
impl Debug for WorkerRegistry
Auto Trait Implementations§
impl Freeze for WorkerRegistry
impl RefUnwindSafe for WorkerRegistry
impl Send for WorkerRegistry
impl Sync for WorkerRegistry
impl Unpin for WorkerRegistry
impl UnsafeUnpin for WorkerRegistry
impl UnwindSafe for WorkerRegistry
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
Mutably borrows from an owned value. Read more
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>
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 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>
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