looplab / eventhorizon

Event Sourcing for Go!
Apache License 2.0
1.58k stars 195 forks source link

[eventstore] Async EventStore for Kafka #163

Open mumia opened 6 years ago

mumia commented 6 years ago

Was wondering if anyone has wrangled with implementing an asynchronous EventStore to user with Kafka and other store engines?

Could we implement some version of the event store that would return some type of promise object and allow for error/success handling?

type AsyncEventStore interface {
    // Save appends all events in the event stream to the store.
    Save(ctx context.Context, events []Event, originalVersion int) chan<- error

    // Load loads all events for the aggregate id from the store.
    Load(context.Context, UUID) (chan<- []Event, chan<- error)
}

Food for thought. Comments welcome.

Will try to implement something.

maxekman commented 6 years ago

It does sound interesting!

Is there a possibility to wait for the event to be written inside your implementation? It is important that the EventStore.Save() method fully saves the event and increments the version atomically, otherwise there will be no guarantee that the command was successful.

mumia commented 6 years ago

@maxekman Yes, when I woke up today I realised that I could use the async write inside the EventStore.Save. This way we use efficient and reliable writes in kafka and don't break the current implementation of the Store. Will implement something and open a PR for you to check.

maxekman commented 6 years ago

Sounds really good, looking forward to see it!

bweston92 commented 6 years ago

Hi @mumia sounds interesting, anything that we can help with?

chriskolenko commented 6 years ago

Any updates on this?