CQRS in Go series:
Part 1 : the aggregate, Transition() and Clone()
Part 2 : command handlers without side effects
Part 3 : sagas and event choreography
Part 4 : PostgreSQL as an event store
The first three parts laid the groundwork: immutable aggregates, pure command handlers, sagas through choreography. One central question remains — where do we persist the events? This part answers that question using PostgreSQL as an append-only event store, with no additional dependencies.
Why PostgreSQL and not EventStoreDB or Kafka
EventStoreDB is an excellent tool, designed specifically for event sourcing. But it's an additional component to deploy, monitor, back up, and maintain. For a team already running PostgreSQL in production, adding EventStoreDB means doubling the operational footprint for a database.
Kafka is often mentioned in this context. It's a message bus, not an event store.…