yevhen / Streamstone

Event store for Azure Table Storage
Other
395 stars 64 forks source link

Documentation / tests for snapshots #38

Closed brcarey closed 7 years ago

brcarey commented 7 years ago

This is a question: is there any documentation or tests for the snapshot feature mentioned in the readme.md?

Synchronous (inline) projections and snapshots

brcarey commented 7 years ago

Kudos for the lib by the way, very easy to integrate, and very tidy codebase

yevhen commented 7 years ago

Hi! Ye, this is the most complicated feature and it doesn't have docs ))

Example is here and more advanced example is here

In a nutshell, this feature is based on WATS ability to include multiple entities in a singe batch transaction (ETG). That's why I call this synchronous inline projections, cause it's just additional rows stored in a same partition. For example you can have secondary consistent index(es) for events (just include same event but with different property chosen as RowKey) and then use RowPrefix queries or you can store mementos (snapshots) of Aggregate state as a row (and then query it).

Streamstone has built-in change tracker for additional includes that could be used during replay of events for creating those projections in a batched way. Streamstone automatically cuts the batch taking into account all additional entity includes. Tests here.

Hope this was helpful ))

brcarey commented 7 years ago

Thanks, was able to figure it out via looking at S06 (and some trial and error). Have you come across the need to handle event schema changes after an event has been raised in production? Do you just opt for a new version (type) for the event?

yevhen commented 7 years ago

Ye, new version is a better option, but it depends on consumers. If you are the only consumer and event changes are non-breaking (ie new field with default value added) and old events could be replayed safely - I just add it to existing ))

I would recommend getting this book https://leanpub.com/esversioning