← 返回 doordash 的题目列表Bootstrap API: Orchestrate Sequential Calls to Multiple Services With Partial-Failure Handling
类型:online_judge
Problem: Implement a Bootstrap API (Orchestrator/Aggregator)
You are asked to implement a backend endpoint called a Bootstrap API. This API must call three downstream services in order, process each result, and aggregate them into a final response.
Requirements
Sequential orchestration: call Service A -> Service B -> Service C serially.
Result processing: after each call completes, process/transform the returned data as needed and populate the final response.
Partial-failure handling:
Any downstream call may fail (exception / error response / timeout).
If a service call fails:
the corresponding output fields are allowed to be set to null/empty;
do not fail the whole request—continue to the next service;
still return the overall aggregated response.
Output: return a single aggregated response containing the portions contributed by each service (or null for failed parts).
Constraints
You do not need real network calls; you may simulate calls via functions or stubbed clients.
Focus: orchestration logic, resilience, and clean structure.
What to implement
Define three service-client call functions (or interfaces) and the main bootstrap() handler.
Implement sequential calls, per-call processing, and error fallback inside bootstrap().
Abstract example
call_service_a() returns {...} or raises
call_service_b() returns {...} or raises
call_service_c() returns {...} or raises
bootstrap() should return something like:
{
"a": { /* or null */ },
"b": { /* or null */ },
"c": { /* or null */ }
}
Typical follow-ups
How would you test it? (all-success, single-failure, multi-failure, timeouts, etc.)
How would you optimize it? (concurrency, retries, timeouts, circuit breakers, caching, graceful degradation, observability, etc.)
Example
Input
(no input)
Output
{"a": {"foo": 1}, "b": {"bar": 2}, "c": {"baz": 3}}