Event
A record of something meaningful that happened in the business domain.
An event is a record of something meaningful that happened in your business domain. It's a verb in past tense: OrderPlaced, PaymentReceived, TicketCanceled. It describes a fact that already occurred and can't be changed.
The important idea here is responsibility. Without events, the function that places an order also triggers notifications, invoicing, and warehouse updates. With events, it does one thing: save the order and publish OrderPlaced. Other parts of the system subscribe and react independently.
This reversal decouples the publisher from all its consumers. Adding a new reaction to an order doesn't require changing the PlaceOrder function. The publisher doesn't even know how many subscribers exist or what they do.
When designing events, focus on what happened, not what should happen next. An event named SendWelcomeEmail is a disguised command. UserSignedUp is a proper event. The difference is subtle but important: events leave the reaction up to subscribers, while commands tell someone what to do.
On an Event Storming board, events are the orange sticky notes that anchor the timeline. Mapping a domain as a sequence of events is the most direct way to see how it actually works.
Domain events also serve as an audit trail. When you follow the history of events, you can reconstruct what happened in the system and why. This makes debugging and analytics much easier.
Sometimes, events are simply stored in the database. Often, they flow through a Pub/Sub system. The Outbox pattern ensures events are published reliably, even when the database and message broker are separate systems.
References
- How to use basic CQRS in Go — Explains how CQRS pairs with event-driven architecture and event sourcing. Events become the bridge between commands and queries, especially in systems with strict audit requirements.
- Distributed Transactions in Go: Read Before You Try — Shows how event-driven patterns replace distributed transactions. Instead of coordinating locks across services, you publish events and let subscribers react independently.
- Introducing Watermill - Go event-driven applications library — Introduces Watermill, a Go library for building event-driven applications. Covers event sourcing, CQRS, and working with message streams using a unified API.
- Using MySQL as a Pub/Sub — Demonstrates storing and processing domain events using SQL databases. Useful when you need event persistence without dedicated messaging infrastructure.
- Software Dark Ages — Introduces Event Storming as a technique for exploring complex business domains. The session starts by building a flow of Domain Events to map out how the system works.
- Live website updates with Go, SSE, and htmx — Uses event-driven patterns with Watermill to push live updates from backend to frontend via Server-Sent Events. Shows a practical example of publishing and subscribing to events.
- Durable Background Execution with Go and SQLite — Explains how Event-Driven Architecture supports durable execution. Uses Watermill as an event bus to ensure background tasks complete reliably despite failures.
- Event-Driven Architecture: The Hard Parts — Dives into real-world challenges of event-driven architecture, including observability, debugging async systems, and hidden traps that come with decoupling services through events.
- Synchronous vs Asynchronous Architecture — Compares synchronous and asynchronous approaches, covering when event-driven architecture is worth the added complexity. Discusses event schemas, Event Sourcing, and migration strategies.
- Watermill: from a hobby project to 8k stars on GitHub — Shares the story of building Watermill, the event-driven library for Go. The goal was to make building event-driven applications as easy as building HTTP handlers.
- The Distributed Monolith Trap (And How to Escape It) — Discusses Event Storming as a technique for discovering system boundaries by mapping domain events. Events help identify where to split or merge services.
- DDD: A Toolbox, Not a Religion — Covers domain events as part of the DDD toolbox. Event Storming uses a notation of domain events to explore how the system works.
- AMA #1: Clean Architecture, Learning, Event-Driven, Go — Answers community questions about event-driven architecture, including when to use async communication and how events simplify chains of service calls.