Skip to main content

Module fetcher

Module fetcher 

Source
Expand description

Coalesced, failover federation fetch of raw event bytes.

Service::fetch is the entry point; behind it a single worker task owns every in-flight fetch and the dedup map, so no lock guards them. The per-fetch work splits across the submodules: candidate selection, the federation transport, and response validation.

ModulesΒ§

error πŸ”’
Internal failure type for a fetch.
inflight πŸ”’
Single-flight bookkeeping for one in-flight fetch.
opts πŸ”’
Caller contract and result types for a fetch: Opts in, Outcome out.
select πŸ”’
Candidate server selection for a fetch.
transport πŸ”’
Federation transport: an Op and target server in, raw response bytes out.
validate πŸ”’
Two-tier response validation: a cheap conformance check, then an opt-in deep PDU pass (event id, content hashes, signatures) that runs only for event ops with those checks enabled. The per-check toggles live on Opts.
worker πŸ”’
The fetch worker loop: one task owning every in-flight fetch, lock-free.

StructsΒ§

Msg πŸ”’
Request to the worker. The worker replies with a subscription to the coalesced result, deferring the reply under backpressure until a slot frees.
Opts
Caller contract. event_id is the sought datum for Op::Event / Op::AuthEvent / Op::AuthChain / Op::StateIds and a reference point for the others.
Outcome
Raw response body plus the server that answered. bytes is ref-counted so concurrent callers coalesced onto one fetch share a single buffer.
Service

EnumsΒ§

FanoutGrowth
Per-round width schedule for staged fan-out: how many candidate servers a fetch races concurrently in each escalation round, before the worker’s per-round ceiling and remaining-budget clamps. Fixed(1) (the Opts::new default) reproduces strictly-sequential attempts.
Op
Federation endpoint a fetch targets. The dedup key folds this in, so two callers asking for the same event over different endpoints do not coalesce.

ConstantsΒ§

REQUESTS_MAX πŸ”’
Upper bound on concurrent in-flight fetches across all keys.

FunctionsΒ§

await_result πŸ”’

Type AliasesΒ§

EventWindow
Event-id window for the batch ops, inline-sized for the common single-prev case and spilling to the heap past that.