pub struct Worker { /* private fields */ }Expand description
Any number of workers can share a database; each message is handled by one.
Implementations§
Source§impl Worker
impl Worker
pub fn job<Args: 'static>( self, name: &'static str, job: impl Call<JobContext, Args>, ) -> Self
Source§impl Worker
impl Worker
pub fn new(db: Db) -> Self
Sourcepub fn on<E: Event, Args: 'static>(
self,
name: &'static str,
job: impl Call<JobContext, Args>,
) -> Self
pub fn on<E: Event, Args: 'static>( self, name: &'static str, job: impl Call<JobContext, Args>, ) -> Self
Runs job for each E raised.
Sourcepub fn every<Args: 'static, J: Call<JobContext, Args>>(
self,
name: &'static str,
cadence: impl Into<Cadence>,
job: J,
) -> Self
pub fn every<Args: 'static, J: Call<JobContext, Args>>( self, name: &'static str, cadence: impl Into<Cadence>, job: J, ) -> Self
At an interval, first as soon as the schedule is new; or at a WallClock time, first
when the zone’s clocks next show it.
Sourcepub fn each<A: Aggregate, QueryArgs: 'static, Args: 'static>(
self,
name: &'static str,
interval: Duration,
items: impl Call<JobContext, QueryArgs, Outcome = Vec<A>>,
action: &'static str,
job: impl Call<JobContext, Args>,
) -> Self
pub fn each<A: Aggregate, QueryArgs: 'static, Args: 'static>( self, name: &'static str, interval: Duration, items: impl Call<JobContext, QueryArgs, Outcome = Vec<A>>, action: &'static str, job: impl Call<JobContext, Args>, ) -> Self
Each record’s job runs with its own retries.
Sourcepub fn mirror<M: Mirror>(self, name: &'static str) -> Self
pub fn mirror<M: Mirror>(self, name: &'static str) -> Self
A new mirror first copies every record its source has, once.
Sourcepub fn max_attempts(self, max_attempts: NonZeroU16) -> Self
pub fn max_attempts(self, max_attempts: NonZeroU16) -> Self
At least one, as none would leave every message unhandled:
ⓘ
fn never(worker: sofie_db::worker::Worker) -> sofie_db::worker::Worker {
worker.max_attempts(0)
}pub fn batch(self, size: NonZeroUsize) -> Self
Sourcepub async fn run(self, shutdown: impl Future<Output = ()> + Send) -> Result<()>
pub async fn run(self, shutdown: impl Future<Output = ()> + Send) -> Result<()>
Refuses repeated job names, intervals out of range and an unkept feed before any work.
Sourcepub async fn drain(&self) -> Result<usize>
pub async fn drain(&self) -> Result<usize>
Pulls every feed first; a failed job is not counted, it is retried once its backoff is over.
pub async fn drain_reporting(&self) -> Result<Drained>
Auto Trait Implementations§
impl !Freeze for Worker
impl !RefUnwindSafe for Worker
impl !UnwindSafe for Worker
impl Forget for Worker
impl Send for Worker
impl Sync for Worker
impl Unpin for Worker
impl UnsafeUnpin for Worker
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