pub struct WorkerPool { /* private fields */ }Expand description
Long-lived worker pool that services all active download jobs.
Implementations§
Source§impl WorkerPool
impl WorkerPool
pub fn new( servers: Arc<Mutex<Vec<ServerConfig>>>, bandwidth: Arc<BandwidthLimiter>, conn_tracker: Arc<ConnectionTracker>, stall_timeout_secs: u64, ) -> Arc<Self>
Sourcepub fn set_max_worker_idle(&self, d: Duration)
pub fn set_max_worker_idle(&self, d: Duration)
Override the worker idle eviction threshold. Tests use this to make the supervisor’s heartbeat check converge in seconds.
Sourcepub fn max_worker_idle(&self) -> Duration
pub fn max_worker_idle(&self) -> Duration
Read current worker idle eviction threshold.
Sourcepub fn eviction_count(&self) -> u64
pub fn eviction_count(&self) -> u64
Lifetime count of worker evictions performed by the heartbeat watchdog. Increases by 1 each time the supervisor reclaims a stalled worker. Test harnesses use this as a positive signal that the Phase 5 idle watchdog actually fired.
Sourcepub fn start(self: &Arc<Self>)
pub fn start(self: &Arc<Self>)
Spawn workers for all currently enabled servers and start the supervisor task. Call once at queue-manager startup.
Sourcepub fn reconcile_servers(self: &Arc<Self>)
pub fn reconcile_servers(self: &Arc<Self>)
Create or tear down workers to match the current server list.
For each enabled server, ensures exactly server.connections workers
exist. Extra workers (from a shrunk limit or disabled server) have
their per-worker shutdown flag flipped so they exit gracefully after
the current article.
Sourcepub fn pause_job(&self, job_id: &str)
pub fn pause_job(&self, job_id: &str)
Pause a job: workers stop pulling its items, and any item currently being held while paused is returned to the queue.
Sourcepub fn resume_job(&self, job_id: &str)
pub fn resume_job(&self, job_id: &str)
Resume a paused job.
Sourcepub fn abort_job(&self, job_id: &str, reason: String)
pub fn abort_job(&self, job_id: &str, reason: String)
Abort a job with a reason. Drains queued items, sets the abort flag, and emits JobAborted via the job’s progress channel.
Sourcepub fn cancel_job(&self, job_id: &str)
pub fn cancel_job(&self, job_id: &str)
Cancel a job silently (no JobFinished / JobAborted emission).
Used by remove_job when the user deletes a job from the queue —
the progress receiver is about to be dropped anyway.
Sourcepub async fn shutdown(self: &Arc<Self>)
pub async fn shutdown(self: &Arc<Self>)
Shut down all workers gracefully. In-flight articles finish first.
pub fn conn_tracker(&self) -> &Arc<ConnectionTracker>
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
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