yevhen / Streamstone

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

Where is the projections sample? #44

Closed tomasaschan closed 10 months ago

tomasaschan commented 6 years ago

The link in the readme points to https://github.com/yevhen/Streamstone/blob/master, but that's a 404. I haven't been able to find the sample by browsing the code, either.

Was it removed? Was support for projections also removed, and if not, where can I read up on how it works?

yevhen commented 6 years ago

Take a look at atomic snapshot example here and check Greg's classic CQRS\ES example using SS here, you will need to switch to inline_projections branch (see readme).

Basically, it's all about being able to include additional table entities along with events and having atomic, transactional behavior (ie Entity Transaction Group). That's what I call synchronous inline projection. The rest is limited only by imagination. I've included entity change tracker to enable replay/rebuild scenarios. You can have a look at tests.

I apologize that I don't have more real-world examples.

tomasaschan commented 6 years ago

Thanks!

A different, but related, question then, that the sample wasn't able to answer for me (maybe the answer is there and I didn't understand it - if so, some clarification would be much appreciated anyway!):

The samples and example projects all seem concerned with storing events, and then querying for entities by ID, but I haven't yet found a sample that lists entitites. Is that what the stream directory is about, or is there something else I should look at?

I'm looking into this for an application that will have some few thousand new entities per year, so it's definitely not a huge data set.

yevhen commented 6 years ago

If by entities you mean aggregates backed by streams, then yes, stream directory example shows how to create stream directory which can be used to list all available streams (entities) in a system (or tenant if you have multi-tenant app).

alexgman commented 5 years ago

Gentlemen, I don't know if this would apply to this post, but I would like to be able to aggregate values from my table.

I'm creating a tiny event-sourcing-style function app, where every invocation of a function will write an event to table storage. An example of such an event would be:

image

How do I create a projection over this table?

The main question that I would need to answer is:

How many connections does each destination currently have?

yevhen commented 5 years ago

It depends on your scale, latency (time-to-answer) and key cardinality requirements. If number of events in the single partition is low (less than 100K) and this is the batch style query, you can simply iterate partition and aggregate in memory. Otherwise, you need to have a background process (other function) that pre-aggregates the events, using SS provided stream sequence number (ie cursor). You can publish notifications about new events via queue to activate that aggregator function, ie projection.