pub struct WorkerPool { /* private fields */ }Expand description
Pool of connected workers with capacity-aware task routing.
Implementations§
Source§impl WorkerPool
impl WorkerPool
pub fn new(heartbeat_timeout_ms: u64) -> Self
pub fn register(&self, info: WorkerInfo)
pub fn deregister(&self, worker_id: &str)
pub fn heartbeat(&self, worker_id: &str, active_tasks: u32)
Sourcepub fn select_and_reserve(&self, task_type: &str) -> Option<String>
pub fn select_and_reserve(&self, task_type: &str) -> Option<String>
Atomically selects a worker and reserves capacity. Returns the worker ID if one is available, or None. This avoids the TOCTOU race between select and dispatch.
Sourcepub fn select_worker(&self, task_type: &str) -> Option<String>
pub fn select_worker(&self, task_type: &str) -> Option<String>
Selects the least-loaded worker for a task type WITHOUT modifying state.
Use select_and_reserve for dispatch to avoid TOCTOU races.
pub fn mark_task_dispatched(&self, worker_id: &str)
pub fn mark_task_completed(&self, worker_id: &str)
pub fn detect_dead_workers(&self) -> Vec<String>
pub fn active_workers(&self) -> Vec<WorkerInfo>
pub fn count(&self) -> usize
pub fn stats(&self) -> PoolStats
Auto Trait Implementations§
impl Freeze for WorkerPool
impl !RefUnwindSafe for WorkerPool
impl Send for WorkerPool
impl Sync for WorkerPool
impl Unpin for WorkerPool
impl UnsafeUnpin for WorkerPool
impl UnwindSafe for WorkerPool
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