pub struct Dispatcher { /* private fields */ }Expand description
Central task dispatcher. Manages worker connections and routes tasks.
Implementations§
Source§impl Dispatcher
impl Dispatcher
pub fn builder() -> DispatcherBuilder
pub async fn start(&self) -> Result<(), DispatchError>
Sourcepub async fn stop(&self)
pub async fn stop(&self)
Gracefully stops the dispatcher. Cancels background tasks and shuts down transport.
pub async fn dispatch( &self, task: Task, ) -> Result<DispatchResult, DispatchError>
pub fn pool_stats(&self) -> PoolStats
Sourcepub fn workers(&self) -> Vec<WorkerInfo>
pub fn workers(&self) -> Vec<WorkerInfo>
List all connected workers with their full info.
Sourcepub fn drain_worker(&self, worker_id: &str) -> Result<(), PoolError>
pub fn drain_worker(&self, worker_id: &str) -> Result<(), PoolError>
Set a worker’s status to Draining. No new tasks will be routed to it, but existing in-flight tasks will finish normally.
Sourcepub fn remove_worker(&self, worker_id: &str) -> Result<(), PoolError>
pub fn remove_worker(&self, worker_id: &str) -> Result<(), PoolError>
Force-remove a worker from the pool and fail all pending tasks assigned to it.
Sourcepub async fn dispatch_to(
&self,
worker_id: &str,
task: Task,
) -> Result<DispatchResult, DispatchError>
pub async fn dispatch_to( &self, worker_id: &str, task: Task, ) -> Result<DispatchResult, DispatchError>
Dispatch a task to a specific worker by ID, bypassing least-loaded selection.
Sourcepub async fn dispatch_with_tag(
&self,
tag: &str,
task: Task,
) -> Result<DispatchResult, DispatchError>
pub async fn dispatch_with_tag( &self, tag: &str, task: Task, ) -> Result<DispatchResult, DispatchError>
Dispatch a task to a worker that has a matching tag. Routes to the least-loaded worker among those with the specified tag.
Auto Trait Implementations§
impl !Freeze for Dispatcher
impl !RefUnwindSafe for Dispatcher
impl Send for Dispatcher
impl Sync for Dispatcher
impl Unpin for Dispatcher
impl UnsafeUnpin for Dispatcher
impl !UnwindSafe for Dispatcher
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