Skip to content

Microservice to hydrate aggregates using version-differences.

License

Notifications You must be signed in to change notification settings

TerrexTech/go-eventstore-query

Repository files navigation

EventStoreQuery

This service provides Aggregates with new events.

This is achieved by comparing Aggregate's current version in its database to the version in EventStore.

How the service Works:

  • The events_meta table contains the aggregate-version for new events. New events will refer version from this table. Check Go-EventPersistence service.

  • The actual events are stored in events table (Event-Store).

  • Every Aggregate maintains its own version. The Aggregate-ID and its current version is sent as request via Kafka-topic esquery.request to this service.

  • This service compares the Aggregate's version with the version in events_meta. The version in events_meta is then incremented by 1, so the new events will get the new version.

  • All the events from event-store (events table) with version > Aggregate-version and < event_meta version are batched into chunks and sent via Kafka-response on the topic provided in EventStoreQuery.

  • The end of Event-Stream is signalled using an extra Event containing Action as __eos__, and UUID matching the provided CorrelationID in EventStoreQuery.

  • These events are to be consumed by the Aggregate service and processed, and the Aggregate will make required changes in its projection. The Aggregate must stop listening for messages when the end-of-stream Event is received, since that signals completion of that request.

Check .env and docker-compose.yaml (docker-compose is only used in tests as of yet) files for default configurations (including the Cassandra Keyspace/Table used).