Skip to main content

Module remote_fetch

Module remote_fetch 

Source
Expand description

Remote reference prefetch (Phases 4–5, plus streaming support).

This is the only part of remote resolve() that performs I/O. It runs at the async edge (CLI / server), before the synchronous, rayon-parallel row generation, and returns the fetched resources so they can be folded into the in-memory resolution pool (see build_resolution_scope in lib.rs). The evaluation core therefore stays pure and the run remains reproducible from (bundle + fetched snapshot).

RemoteResolver holds the config plus a bounded, cross-call cache and a fetch counter, so it serves a whole run:

  • single Bundle — one RemoteResolver::resolve call over all bundle references (prefetch_external_resources);
  • streaming / NDJSON — one resolver shared across every chunk, so a reference recurring across chunks is fetched once and max_fetches is a per-stream cap. The cache is a bounded LRU (with negative caching) so streaming memory stays bounded.

Per resolve call:

  1. Keep only references the allowlist permits and that do not already resolve locally — RemoteResolveConfig::fetch_decision / resolves_in_bundle.
  2. Serve cache hits; for misses, validate each host (literal IPs were explicitly allowlisted; hostnames are resolved via DNS and pinned to addresses that pass is_blocked_address — enforcing the SSRF guard and defeating DNS rebinding), then fetch concurrently under the per-run cap, timeout, size cap, and optional per-host bearer auth.
  3. Cache results (success and miss), follow chained references up to max_depth, and parse the collected JSON into [FhirResource]s of the bundle’s version (skipping anything that fails to parse — non-fatal).

Structs§

RemoteResolver
A reusable remote-resolution engine for one run (a Bundle or an NDJSON stream).

Functions§

prefetch_external_resources
Fetches the allowlisted external references reachable from bundle and returns them as parsed resources to merge into the resolution pool (single-Bundle path).