Module 12 Activity
Scenario
Make the boundaries you do not control fail in ways your callers can act on.
What you build
Per-request sessions, mapped boundary failures, timeouts everywhere and bounded retries.
Steps
- Make the database session a per-request dependency using
yieldandfinally, and prove every session opened is closed. - Map every boundary exception to a specific status. Confirm none reaches the client as a 500.
- Set an explicit timeout on every outbound call, shorter than any gateway in front of you.
- Bound your retries, add jitter, and confirm no 4xx is retried.
- Confine every query to the repository layer and confirm services import no driver.
- Test one service with a fake repository and no database at all.
Evidence to hand in
- The session dependency with the open/close proof.
- The exception-to-status map.
- Timeouts on every outbound call.
- The retry policy with jitter and the retryable set.
- The service test with a fake repository.
Review checklist
- Every session is closed, including on the error path.
- No boundary failure reaches the client as a 500.
- Every outbound call has an explicit timeout.
- No 4xx is retried, and retries carry jitter.
- At least one service is tested with no database.
