Skip to main content

UpdateProcessor

Trait UpdateProcessor 

Source
pub trait UpdateProcessor: Send + Sync {
    // Required method
    fn do_process_update<'life0, 'async_trait>(
        &'life0 self,
        update: Arc<Update>,
        coroutine: Pin<Box<dyn Future<Output = ()> + Send>>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn initialize<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

An abstract base for update processors.

Implementations control how update coroutines are driven (e.g. immediately awaited, batched, prioritised, etc.).

The process_update method is final – it acquires the internal semaphore and then delegates to do_process_update.

Required Methods§

Source

fn do_process_update<'life0, 'async_trait>( &'life0 self, update: Arc<Update>, coroutine: Pin<Box<dyn Future<Output = ()> + Send>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Custom implementation of how to process an update. Must be implemented by the concrete type.

Warning: This method is called by process_update. It should not be called manually.

Provided Methods§

Source

fn initialize<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called once before the processor starts handling updates.

Source

fn shutdown<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called once when the processor is shutting down.

Implementors§