get-eventually / eventually-rs

Event Sourcing for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eventually-core: add Subscriber trait support

ar3s3ru opened this issue · comments

A Subscriber should allow to create subscriptions to new changes happening in the EventStore.

Changes received from the Subscriber should start from when the subscription has started, onwards.

The base idea of a Subscriber is very similar to the EventStore, looking like this:

pub trait Subscriber {
    type SourceId: Eq;
    type Event;
    type Error;

    fn subscribe_all(&self) -> BoxFuture<Result<EventStream<Self>, Self::Error>>;

    // We can provide a default implementation using `subscribe_all`
    fn subscribe(&self, id: Self::SourceId) -> BoxFuture<EventStream<Self>, Self::Error>;
}

The Subscriber can then be used to attach Publishers to relay the events onto message brokers (e.g. Kafka, RabbitMQ), or to run Projectors.