Skip to main content

Worker

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>>>  { ... }
}

Required Methods§

Source

fn kind(&self) -> WorkerKind

Source

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,

Source

fn factory<C>(context: C) -> impl WorkerFactory + 'static
where Self: Sized, C: XmtpSharedContext + 'static,

Provided Methods§

Source

fn metrics(&self) -> Option<DynMetrics>

Source

fn boxed(self) -> Box<dyn Worker>
where Self: Sized,

Box the worker, erasing its type

Source

fn spawn( self: Box<Self>, cancel: CancellationToken, ) -> Instrumented<Pin<Box<dyn Future<Output = WorkerKind> + Send>>>

Implementors§

Source§

impl<Context> Worker for CommitLogWorker<Context>
where Context: XmtpSharedContext + 'static,

Source§

impl<Context> Worker for ConfigurationWorker<Context>
where Context: XmtpSharedContext + 'static,

Source§

impl<Context> Worker for SyncWorker<Context>
where Context: XmtpSharedContext + 'static,

Source§

impl<Context> Worker for DisappearingMessagesWorker<Context>
where Context: XmtpSharedContext + 'static,

Source§

impl<Context> Worker for TaskWorker<Context>
where Context: XmtpSharedContext + 'static,