get-eventually / eventually-rs

Event Sourcing for Rust
MIT License
561 stars 30 forks source link

eventually-sled: new backend based on sled db #122

Open pwoolcoc opened 4 years ago

pwoolcoc commented 4 years ago

I brought up a possible backend implementation using the sled database, and danilo suggested I open a tracking issue to discuss it. (I'll post more specific thoughts later, just wanted to get this open for now so I didn't forget)

ar3s3ru commented 4 years ago

Hey @pwoolcoc, thanks for opening the issue!

For a new backend implementation, you need to implement the following traits:

  1. EventStore, for appending and streaming events on request
  2. EventSubscriber, for opening event streams receiving all new events committed to the store from when the stream has been opened
  3. (Optional) A persistent Subscription implementation (e.g. https://ar3s3ru.github.io/eventually-rs/eventually/postgres/struct.Persistent.html)

For now, let's only consider the first two traits.

For point 2. it seems pretty easy to implement using the reactive semantics offered by sled.

For point 1. we need to figure out how to store the events and how to stream them back. When storing and streaming, we need double indexing: one on a single aggregate level (aggregate id), and one on aggregate type level (aggregate type id).

Also for point 1., we need to figure out a way to use optimistic concurrency in the write operations, in order to prevent concurrent writes scenarios.

What do you think? @pwoolcoc

ar3s3ru commented 4 years ago

Hey @pwoolcoc, if you're still interested in adding this feature, you can check out #128 for reference: it adds support for Redis backend.

pwoolcoc commented 4 years ago

@ar3s3ru thanks! sorry I didn't respond to this thread earlier, but I'm definitely still interested in doing this and I appreciate the pointers and the reference!

pwoolcoc commented 4 years ago

Ok, initial thoughts, in no particular order:

pwoolcoc commented 4 years ago

@ar3s3ru quick question: I'm hoping to have a POC of this soon, should I open a PR and try to get it in-tree or should I just keep in my own repo?

ar3s3ru commented 4 years ago

Hey @pwoolcoc :wave:

Feel free to open a PR to have the CI tests run :smile:

ar3s3ru commented 4 years ago

Also, now that I've created an org for eventually, I was considering moving eventually-postgres and eventually-rust out in their own respective repositories in the org.

Maybe we can do the same with eventually-sled.

Issues #131 #132