Resilient REST Call Abstraction
Design a reusable REST dependency layer with explicit deadlines, safe retries and honest uncertain outcomes.
Problem statement
For this exercise, assume several application services need a shared REST-call abstraction for three external dependencies. A caller supplies a named operation, validated inputs, request context and a deadline; the abstraction translates it into an authenticated HTTP request and a stable typed result.
Support cancellation and bounded retry policies without hiding whether a remote write might already have happened. Read-only operations may be retried; a write may be retried only when the dependency explicitly supports a caller-provided idempotency key. Keep credentials isolated by dependency and caller scope.
Cover the client architecture and its configuration/operational boundaries, not implementation code. Offline job execution, a general API gateway and a claim of exactly-once remote execution are out of scope.
This practice exercise is based on an interview-preparation compilation, not an independently dated interview occurrence.
What to build
- Invoke a configured operation and return a typed success or a stable validation, dependency, timeout, cancellation or uncertain-write outcome.
- Carry an end-to-end deadline through connection, response and permitted retry attempts, and propagate cancellation without promising remote rollback.
- Apply dependency-specific authentication, request mapping and safe retry configuration while keeping caller scopes and dependency failures isolated.
At scaleExercise target
- 100 application processes generate 5,000 dependency calls per second in aggregate across three independently failing dependencies.
- A caller normally has a two-second end-to-end deadline; retries share that budget rather than receiving a new one.
- During a dependency outage, limit total attempts to at most twice admitted original requests and bound per-process in-flight work. Reject or shed excess work rather than accumulating an unbounded queue.