Skip to main content

EventBusTrait

Trait EventBusTrait 

Source
pub trait EventBusTrait: Send + Sync {
    // Required methods
    fn get_sender(&self) -> UnboundedSender<EngineMessage>;
    fn subscribe<'life0, 'async_trait>(
        &'life0 self,
        topics: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<EngineMessage>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe_with_offsets<'life0, 'async_trait>(
        &'life0 self,
        topics: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<LegacyMessageEnvelope>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe_with_sequence<'life0, 'async_trait>(
        &'life0 self,
        topics: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<MessageEnvelope>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn start_processing<'async_trait>(
        self: Arc<Self>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn replay_from_offsets<'life0, 'async_trait>(
        &'life0 self,
        offsets: TopicOffsets,
        handler: ReplayHandler,
    ) -> Pin<Box<dyn Future<Output = Result<TopicOffsets, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_current_offsets(&self) -> TopicOffsets;
    fn get_current_sequence(&self) -> u64;
}

Required Methods§

Source

fn get_sender(&self) -> UnboundedSender<EngineMessage>

Get a sender to publish events

Source

fn subscribe<'life0, 'async_trait>( &'life0 self, topics: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<EngineMessage>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to specific topics and get a receiver for events

Source

fn subscribe_with_offsets<'life0, 'async_trait>( &'life0 self, topics: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<LegacyMessageEnvelope>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to specific topics and get a receiver for events WITH legacy offset metadata. Use this when you need to track exactly which offsets you’ve processed (for snapshots).

Source

fn subscribe_with_sequence<'life0, 'async_trait>( &'life0 self, topics: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<MessageEnvelope>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to specific topics and get a receiver for events WITH sequence metadata. Use this when you need monotonic ordering.

Source

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

Start processing events (forwarding between channels)

Source

fn replay_from_offsets<'life0, 'async_trait>( &'life0 self, offsets: TopicOffsets, handler: ReplayHandler, ) -> Pin<Box<dyn Future<Output = Result<TopicOffsets, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Replay events from specific offsets until caught up to the current head.

This is used during startup to replay events from the last snapshot to the current state before marking the service as ready.

Returns Ok(final_offsets) when caught up, where final_offsets are the high water marks that were reached. Returns Err if replay fails. The handler is called for each replayed message.

Source

fn get_current_offsets(&self) -> TopicOffsets

Get the current consumer offsets for all topics.

Returns the latest offset processed for each topic/partition. Used by snapshot services to record the exact position in the event stream that corresponds to the snapshot state.

For in-process implementations, returns an empty map.

Source

fn get_current_sequence(&self) -> u64

Get the current sequence number (highest dispatched).

Implementors§