Event-Driven Rails in Practice
How we built a lightweight event bus inside a Rails monolith - schemas, idempotency, error isolation, and the one-line call that decouples everything.
8 stories
How we built a lightweight event bus inside a Rails monolith - schemas, idempotency, error isolation, and the one-line call that decouples everything.
Events decouple side effects. But what if the side effect is work that needs doing? Here's how we turned domain events into an auto-managing task board.
Tracing a single leave approval from emit_async through schema extraction, Sidekiq dispatch, subscriber routing, and email delivery. The whole chain, no gaps.
After building an event system across every domain, here's what worked, what surprised us, and the one thing we'd do differently.
How we decoupled notifications from operations with a subscribe_to DSL that routes events to the right mailer, the right recipients, automatically.
How our event bus dispatches to subscribers with pattern matching, circuit breakers, and exactly-once delivery via Redis.
How we define events with a 15-line DSL, auto-register them, and serialize payloads safely. The building blocks of our event system.
A payroll approval triggers six side effects. We needed them out of the operation. Here's the problem that led us to event-driven architecture.