[][src]Trait rust_transit::EventManager

pub trait EventManager {
#[must_use]    fn send<'life0, 'life1, 'async_trait, T>(
        &'life0 mut self,
        tenant: &'life1 str,
        t: T
    ) -> Pin<Box<dyn Future<Output = EventResult<()>> + Send + 'async_trait>>
    where
        T: EventType + Serialize + Send,
        T: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn add_consumer<T, C>(
        &mut self,
        tenant: &str,
        c: C
    ) -> EventResult<ConsumerID>
    where
        T: EventType + 'static + Sync + Send + DeserializeOwned,
        C: Consumer<T> + 'static + Clone + Sync + Send
;
fn remove_consumer(&mut self, cid: &ConsumerID) -> EventResult<()>;
fn close(&mut self) -> EventResult<()>;
fn clean(&mut self) -> EventResult<()>; }

The Event Manager is the main trait, offering functions to send and consume events

Required methods

#[must_use]fn send<'life0, 'life1, 'async_trait, T>(
    &'life0 mut self,
    tenant: &'life1 str,
    t: T
) -> Pin<Box<dyn Future<Output = EventResult<()>> + Send + 'async_trait>> where
    T: EventType + Serialize + Send,
    T: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Send an event optionally related to a tenant (use empty string for no tenant)

fn add_consumer<T, C>(&mut self, tenant: &str, c: C) -> EventResult<ConsumerID> where
    T: EventType + 'static + Sync + Send + DeserializeOwned,
    C: Consumer<T> + 'static + Clone + Sync + Send

Add a consumer to handle specific events, optionally for a specific tenant (use empty string for no tenant)

fn remove_consumer(&mut self, cid: &ConsumerID) -> EventResult<()>

Remove a consumer given its ID

fn close(&mut self) -> EventResult<()>

Close the manager and all the resources it holds

fn clean(&mut self) -> EventResult<()>

Clean the underlying system, usually to ensure tests start from a clean slate

Loading content...

Implementors

Loading content...