Menu

CQRS in Go — Part 4: PostgreSQL as an event store
📰

CQRS in Go — Part 4: PostgreSQL as an event store

DEV Community·Odilon HUGONNOT·7 months ago
#TQ3iueEw
#eventsourcing#cqrs#go#postgres#software
Long article (2478 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.