Expand description
Canonical ureq::Agent construction + named HTTP timeout constants.
Before this module, ureq::AgentBuilder::new().timeout(...).build() was
inlined at 7 production sites (server_client, daemon, oci x3, upgrade x2)
with three of the timeouts already drifted. Worse, cfgd/src/ai/client.rs
used bare ureq::post(...) with no timeout at all — the Anthropic call
could hang the CLI indefinitely. Using these constants + http_agent
replaces every inline Duration::from_secs(...) literal and keeps future
timeout changes in one place.
Constants§
- HTTP_
AI_ TIMEOUT - Anthropic API requests from
cfgd generateandcfgd ai. Claude latency for agentic tool use is normally a few seconds; 120s is a ceiling for pathological slow networks. Must have some timeout — before this constant the request had none at all. - HTTP_
API_ TIMEOUT - Device gateway API calls (checkin, drift, enrollment) — small JSON payloads. Kept short because the gateway is nearby and responses are small.
- HTTP_
OCI_ TIMEOUT - OCI registry blob / manifest operations (push, pull, multi-platform index). Module layers and image blobs can be hundreds of MiB; 300s accommodates cold caches and slow registry peers.
- HTTP_
UPGRADE_ TIMEOUT - GitHub Releases API queries + binary archive downloads for self-upgrade. 300s covers slow mirrors; the streaming download applies per-chunk.
- HTTP_
WEBHOOK_ TIMEOUT - Outbound webhook notifications (drift alerts, check-in callbacks). Short — the caller doesn’t wait on user-visible output; a slow peer should not starve the daemon’s notification loop.
Functions§
- http_
agent - Build a
ureq::Agentwithtimeoutapplied. Exists so every call site that wants a timeout can use one line and we can changeAgentBuilderconfiguration (user-agent defaults, connection pooling, TLS options) in exactly one place if it becomes necessary.