EventSaucePHP / EventSauce

A pragmatic event sourcing library for PHP with a focus on developer experience.
https://eventsauce.io/
MIT License
817 stars 82 forks source link

[WIP] Subscriptions & projection engine #213

Open Robertbaelde opened 1 year ago

Robertbaelde commented 1 year ago

This PR introduces subscriptions and projections to EventSauce.

Subscriptions

Subscriptions are a subscription to a set of messages from the MessageStorage. The simplest form of subscription would be the offset subscription, returning all events since a specific offset. More complex subscriptions can be created, for example on aggregateId or on a specific partition of a stream.

Projections

Currently there are some message consumer interfaces and there is a replay functionality in EventSauce. However oftenly you'd want a projector that is autonomous, and keeps track of its own offset to the stream. This gives more flexibility with replaying projectors, and handling projections in parallel.

Todo:

frankdejonge commented 1 year ago

I'm wondering if the Checkpoint should contain the ProjectionId since it's always for that specific, releasing it would then only need to contain the checkpoint. WDYT, @Robertbaelde ?

Robertbaelde commented 1 year ago

I'm wondering if the Checkpoint should contain the ProjectionId since it's always for that specific, releasing it would then only need to contain the checkpoint. WDYT, @Robertbaelde ?

I see checkpoints as part of a subscription to a stream, and not per-se projection related. So those subscriptions could be used for other stuff than projections (Reactors, process managers, message publisher or other stuff). Happy to discuss further though.