Trait Worker
Source pub trait Worker:
MaybeSend
+ MaybeSync
+ 'static {
// Required methods
fn kind(&self) -> WorkerKind;
fn run_tasks<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn NeedsDbReconnect>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn factory<C>(context: C) -> impl WorkerFactory + 'static
where Self: Sized,
C: XmtpSharedContext + 'static;
// Provided methods
fn metrics(&self) -> Option<DynMetrics> { ... }
fn boxed(self) -> Box<dyn Worker>
where Self: Sized { ... }
fn spawn(
self: Box<Self>,
cancel: CancellationToken,
) -> Instrumented<Pin<Box<dyn Future<Output = WorkerKind> + Send>>> ⓘ { ... }
}
Box the worker, erasing its type