๐ WAYPOINT LESSON
Checkpoint โ The Public API Client
โญโญ intermediateโณ 25 min read๐ Lesson 128 of 265
Compose the pieces: typed client over a stub handler, mapped outcomes, retries with capped backoff, cancellation honored.
The gate (mini-build)
A resilient API client โ the shape from the lesson, assembled:
ApiClient(HttpClient http)โ injected client (Module 11 discipline).GetUserAsync(int id, CancellationToken ct)โ GET/users/{id}. Outcomes:"user:<name>"on 200,"notfound"on 404,"failed"on any other status.GetUserWithRetryAsync(int id, int maxAttempts, CancellationToken ct)โ same contract, but 5xx attempts are retried with the harness's recorded delays (non-decreasing, capped at 50 ms); 404 is NOT retried.- Cancellation wins: a pre-cancelled token throws OperationCanceledException before any request.
Provided: CjStubHandler (records requests, replays scripted responses,
records fake delays).