pub struct WorkerService<Q, S, E, F>{ /* private fields */ }Expand description
Worker service that processes jobs from the queue.
This service polls for pending jobs and processes them using the
HarvestPipeline. It supports both full harvest+embed and metadata-only
modes, and graceful shutdown via cancellation tokens.
Implementations§
Source§impl<Q, S, E, F> WorkerService<Q, S, E, F>
impl<Q, S, E, F> WorkerService<Q, S, E, F>
Sourcepub fn new(
queue: Q,
pipeline: HarvestPipeline<S, E, F>,
config: WorkerConfig,
) -> Self
pub fn new( queue: Q, pipeline: HarvestPipeline<S, E, F>, config: WorkerConfig, ) -> Self
Create a new worker service.
Sourcepub async fn run<WR, HR>(
&self,
cancel_token: CancellationToken,
worker_reporter: &WR,
harvest_reporter: &HR,
) -> Result<(), AppError>where
WR: WorkerReporter,
HR: ProgressReporter,
pub async fn run<WR, HR>(
&self,
cancel_token: CancellationToken,
worker_reporter: &WR,
harvest_reporter: &HR,
) -> Result<(), AppError>where
WR: WorkerReporter,
HR: ProgressReporter,
Run the worker until cancelled.
The worker will:
- Poll for available jobs
- Claim and process jobs
- Handle retries on failure
- Release jobs on graceful shutdown
Sourcepub async fn process_single_job<WR, HR>(
&self,
job_id: Uuid,
cancel_token: CancellationToken,
worker_reporter: &WR,
harvest_reporter: &HR,
) -> Result<(), AppError>where
WR: WorkerReporter,
HR: ProgressReporter,
pub async fn process_single_job<WR, HR>(
&self,
job_id: Uuid,
cancel_token: CancellationToken,
worker_reporter: &WR,
harvest_reporter: &HR,
) -> Result<(), AppError>where
WR: WorkerReporter,
HR: ProgressReporter,
Process a single job by ID (for one-off execution, e.g., CLI).
This method is useful for processing a specific job without running the full polling loop.
Auto Trait Implementations§
impl<Q, S, E, F> Freeze for WorkerService<Q, S, E, F>
impl<Q, S, E, F> RefUnwindSafe for WorkerService<Q, S, E, F>
impl<Q, S, E, F> Send for WorkerService<Q, S, E, F>
impl<Q, S, E, F> Sync for WorkerService<Q, S, E, F>
impl<Q, S, E, F> Unpin for WorkerService<Q, S, E, F>
impl<Q, S, E, F> UnsafeUnpin for WorkerService<Q, S, E, F>
impl<Q, S, E, F> UnwindSafe for WorkerService<Q, S, E, F>
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