Writing backend APIs in a functional programming style
summary
Pattern claims: separate business logic from I/O using a functional-core, imperative-shell and keep each RPC result as a Result so error handling changes only touch business code. Implementation shows a gRPC endpoint that calls three services (Dasher, customer, delivery), uses Kotlin coroutines with structured concurrency and Deferred fields to run calls concurrently, and converts to lazy async (start=lazy) to conditionally skip calls. Uses supervisor scope, per-RPC Result wrapping, and a working example that lets errors be mapped without refactoring.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 0:23The problem
- 2:56The key idea
- 3:39Functional shell pattern
- 10:13New product requirements
- 12:22Product requirements
- 12:46Structured concurrency
- 15:54Lazy loading
- 21:35Supervisor and Coroutine scope
- 23:01Summary
- 24:03Questions
related talks
47mRediscovering gRPC with Kotlin coroutines
51mFunctional fashion for Kotlin projects
48mKotlin & Functional Programming: pick the best, skip the rest
41mArchitectures Using Functional Programming Concepts
46mWhy Care About Functional Programming
42mBuilding Microservices with Kotlin and gRPC
29mPure Scala Approach for Building Frontend and Backend Apps
41mBuilding microservices with Kotlin and gRPC
