Expand description
Worker service for processing harvest jobs from the queue.
This module provides the WorkerService that polls for pending jobs
and processes them using the HarvestService.
§Architecture
The worker follows a poll-based model:
loop {
1. Check for cancellation
2. Claim next available job (SELECT FOR UPDATE SKIP LOCKED)
3. Process job using HarvestService
4. Update job status (completed/failed/cancelled)
5. If no jobs available, sleep for poll_interval
}§Graceful Shutdown
On cancellation token trigger:
- Stops claiming new jobs
- Allows current job to complete or cancel gracefully
- Releases any claimed jobs back to the queue
§Example
ⓘ
use ceres_core::worker::{WorkerService, WorkerConfig, TracingWorkerReporter};
use ceres_core::progress::TracingReporter;
use tokio_util::sync::CancellationToken;
let worker = WorkerService::new(job_queue, harvest_service, WorkerConfig::default());
let cancel = CancellationToken::new();
worker.run(cancel, &TracingWorkerReporter, &TracingReporter).await?;Structs§
- Silent
Worker Reporter - Silent worker reporter that ignores all events.
- Tracing
Worker Reporter - Tracing-based worker reporter for CLI/server logging.
- Worker
Service - Worker service that processes jobs from the queue.
Enums§
- Worker
Event - Events emitted by the worker during operation.
Traits§
- Worker
Reporter - Trait for reporting worker events.