1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use async_trait::async_trait;

use crate::store::StoreEvent;
use crate::Aggregate;

#[cfg(feature = "kafka")]
pub mod kafka;
#[cfg(feature = "rabbit")]
pub mod rabbit;

/// The responsibility of the [`EventBus`] trait is to publish an event on a specific bus implementation.
#[async_trait]
pub trait EventBus<A>: Sync
where
    A: Aggregate,
{
    /// Publish an [`Aggregate`] event on an [`EventBus`] defined by the user.
    ///
    /// All the errors should be handled from within the [`EventBus`] and shouldn't panic.
    async fn publish(&self, store_event: &StoreEvent<A::Event>);
}