← 返回 doordash 的题目列表Code Craft: Aggregated Bootstrapper API
类型:online_judge
Problem: Implement an Aggregated Bootstrapper API
Implement an HTTP API (you may use pseudocode for the API and core logic) that fetches multiple pieces of bootstrap data in one call during app/service startup. The API must call multiple downstream services (or data sources) concurrently and aggregate results into a single response.
Requirements
The API accepts request parameters (e.g., user_id, location, device; you can choose but must specify clearly).
Call multiple downstream endpoints concurrently (at least 3), such as:
User profile
Available stores / recommendations
Active order / delivery status
Promotions / credits
Aggregate downstream responses into one unified JSON response.
Partial failure handling: if some downstream calls fail, still return HTTP 200, and mark which modules failed or were degraded.
Timeouts and fallbacks: configure per-downstream timeouts; on timeout return default/empty values.
Constraints / Boundaries
Specify the concurrency model (thread pool / async / coroutines).
Optional caching: what to cache, cache keys, and TTL.
Idempotency and observability: include request id and downstream latency stats.
Output
Provide: API contract (path, request/response examples) and core aggregation pseudocode/code skeleton.
Example
Input
GET /bootstrap?user_id=1&location=SF&request_id=abc
Output
200 OK
{
"request_id": "abc",
"data": {
"profile": {"user_id": "1", "name": "Alice"},
"recommendations": {"stores": ["StoreA","StoreB"], "location": "SF"},
"active_order": {"has_active_order": false}
},
"errors": [],
"meta": {"latency_ms": {"profile": 20, "recommendations": 50, "active_order": 10}}
}