Skip to content

Projectors

Muhammad K Khan edited this page Nov 4, 2019 · 2 revisions

What does all these events add up to 😱

  • What are projectors in an event based application.
  • Why we need them
  • Different strategies to create projections
  • lifebook.core projector architecture

An event is a single splice of a transaction. From a single event's data we should be able to answer everything we need to for that individual event but not for the aggregate. So in order for us to answer: what is the state of this aggregate? We need to sum up the sequence of events for the given aggregate, by apply each event until we end up with up-to-date state for the aggregate. This is what a projectors are in simple terms, they sum up all the events are return an entity back for the aggregate stream.

There are many different strategies to creating projections one is to go to your datastore that has all the events and replay them from the beginning and return the projection (or entity) that is created. Another strategy is to create in the background create projection for each aggregate stream and store them in a document store and the clients retrieve records from this store and don't have to replay all the events.

In our application we choose to store our projections into Postgres SQL, since it has good support for JSON based data and we could easily query the json data and work with it.

test

Helpful links

CQRS

Clone this wiki locally