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
Schedules the concurrent candidate width for each staged fan-out round.
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.