Practical Eff Monad For Micro-services
summary
Built a small article microservice at Zando that wires components with constructor injection using case classes and implicit Reader instances generated by the grafter macros (shapeless-based), removing manual DI. Uses http4s/rou for routes, supports many async backends (Future, Monix/Task, Twitter), and models effects (task, logged, flow ID) with the F monad. Integration and testing use Kiama tree rewriting to swap mocks and enforce singletons; components stay lazy via cats Eval. Approach is production-proven and works for rapid merchant onboarding.
AI-written summary · about
chapters (33)
- 0:00Introduction and motivation
- 1:26Zando's microservice context
- 3:15Article service requirements
- 5:01Component-based design approach
- 6:26Constructor injection with case classes
- 8:57Reader monad for dependency wiring
- 9:41Automating wiring with Shapeless
- 11:47Building the application graph
- 12:28HTTP server and route structure
- 13:53Interfaces and implementations
- 15:17Default implementations and configuration
- 16:20Library integration and readers
- 18:05Unit testing with constructor injection
- 18:46Integration testing with tree rewriting
- 21:55Handling singletons in the graph
- 23:21Lazy evaluation and resource management
- 24:45Starting and stopping the application
- 26:32Summary of component design
- 27:35Introduction to the F monad
- 29:19Encoding effects with F
- 31:05Interpreting F computations
- 32:29Practical effects in components
- 33:32Flow ID effect explained
- 35:20Logging effect and interpreters
- 36:48Testing logging effects
- 38:14Applicative concurrency for microservices
- 39:18Async effects support
- 40:42Reader monad vs component-based DI
- 41:24Common mistakes with F monad
- 42:27Error handling strategies
- 44:31Avoiding DSL effects
- 45:55Component vs effect modeling
- 47:40Conclusion and takeaways
