Expand description
Provider selection algorithm (ADR 001 § Node Selection Algorithm + ADR 008 § Tie-Breaking).
rank_candidates returns the input list ordered best-first (lowest score
first) with the three-tier tie-breaker applied. The caller iterates the
result in order and stops after MAX_PROVIDER_ATTEMPTS failed providers.
Structs§
- Candidate
- A candidate provider produced by content discovery, ready to be ranked.
- Ranked
Candidate - A candidate paired with its computed selection score. Lower score is better.
Constants§
- CHANNEL_
OPEN_ CALLER_ BUDGET - How long a pull is willing to WAIT on a buyer-channel open before giving up on that candidate — not how long the open itself is allowed to take (#1143).
- MAX_
PROVIDER_ ATTEMPTS - Maximum providers to attempt before reporting a fetch failure to the caller (issue #322 — “max 3 provider attempts before returning error”).
- PROBE_
EARLY_ EXIT_ CANDIDATES - How many blob-holding candidates a SINGLE-SOURCE probe round collects before
it stops waiting on the rest.
PROBE_TIMEOUTstays the ceiling — a sparse round that never reaches this count still waits it out — but when this many good providers have already answered, the round selects among them instead of waiting the full window for a straggler or a dead peer that will only time out. The count leaves at least one alternate in hand for per-blob failover while keeping cold-miss discovery latency at the speed of the fastest good answers rather than the ceiling. ADR 001 § Probe response collection. - PROBE_
TIMEOUT - Per-candidate probe timeout. Because candidates are probed concurrently, this also
bounds the whole probe-collection phase. The budget covers connection setup plus one
unpaid probe request/response.
probe_oncedials a fresh connection every call, and the protocol has no 0-RTT path, so even a resumable session pays a handshake round trip before the request goes out — every probe costs two RTTs, not one. At the 250-300 ms inter-continental RTTs this budget is sized against, that puts the furthest candidates at or past this ceiling. Dropping them is the intended trade (a slow candidate must not burn the caller’s miss-latency budget), but this is the first term to revisit if distant-region selection looks too sparse. Both the figure and the trade are ADR 001 § Probe response collection. - PULL_
THROUGH_ OUTER_ SLACK - One-time headroom added on top of the
MAX_PROVIDER_ATTEMPTSsequential per-candidate costs when computing the outer pull-through deadline (#859). It covers the one-timediscover → probe → rankoverhead: work that runs under the outer deadline but does not scale with the attempt count.
Functions§
- outer_
pull_ deadline - Outer deadline for a node-to-node pull-through, derived from the two configured
per-candidate budgets: the stream-open timeout (
cache.node_pull_timeout_sec) and the streaming throughput-floor window (cache.node_pull_stall_window_sec). - rank_
candidates - Rank candidates by selection score, lowest (best) first.