CQRS Handler
ELI5 — The Vibe Check
A CQRS handler is the function that actually does the work when a command or query comes in. Command handlers change state (create, update, delete). Query handlers read state. Keeping them separate means your reads and writes don't step on each other's toes.
Real Talk
In CQRS architecture, handlers are responsible for executing commands (write operations) and queries (read operations) separately. Command handlers validate input, execute business logic, and persist changes. Query handlers retrieve and transform data for read models. This separation allows independent optimization, scaling, and evolution of read and write paths.
When You'll Hear This
"The command handler validates the order and persists it; the query handler reads from a denormalized view." / "We scale query handlers to 10 instances but only need 2 command handlers."
Related Terms
Command Pattern
Every action in a text editor is a Command object: TypeTextCommand, DeleteWordCommand, BoldCommand.
CQRS
CQRS says: the way you write data and the way you read data should be separate systems. Writing (commands) goes to one model optimized for transactions.
Domain Event
A domain event is something meaningful that happened in your business. Not 'row updated in users table' but 'UserRegistered' or 'OrderShipped.
Event Sourcing
Instead of storing 'balance: $100', event sourcing stores 'deposited $200, withdrew $50, withdrew $50'.