Traversals and Scans and CQRS, oh my!
summary
Shows a concrete reservation-service implementation that uses Cats types to validate commands, emit events and update state: validations return Either, events are accumulated with StateT and WriterT, and a list of events plus new state is persisted as snapshots and event appends. Command streams are handled with fs2 mapAccumulate to thread state; persistence runs in evalMap. WriterT allocation becomes a bottleneck in practice, so the recommended optimization is finally tagless for better performance and easier interpretation.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 1:15Understanding CQRS
- 2:38Problems with typical architecture
- 6:00The event-based approach
- 8:24Behavior-driven design
- 10:41Benefits of CQRS
- 12:08Implementation plan
- 14:19Validating commands
- 17:04Stateful validation
- 19:25Applicative combinators
- 21:34Generating events
- 25:40WriterT for logging
- 27:14State mutation
- 30:57StateT for state management
- 34:09Streaming commands
- 37:33Conclusion and resources
related talks
43mCommander: Better Distributed Applications through CQRS and Event Sourcing
52mEvent Sourcing and CQRS
31mTRAVERSALS FOR ALL OCCASIONS
44mFrom REST to CQRS with Clojure, Kafka, & Datomic
31mBoring use cases for exciting types
45mOh, All the things you'll traverse
01h 25mBuilding microservices with event sourcing and CQRS
31mCool toolz in the Scalaz and Cats toolboxes
