ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.Exchange

Description

The shared bounded registry exchanges: run one formed Request and read its response under a response-bound budget, every failure folded into the typed channel at this edge. Two shapes live here, one per whole-buffered response the proxy reads: boundedFetch returns the body as a RegistryResponse; boundedRelay pairs the bounded body with the status the target answered as a PublishRelayResponse.

The npm read data plane (Ecluse.Core.Registry.Npm) and the mirror-write transport (Ecluse.Core.Registry.Publish) fetch through boundedFetch; the first-party publish relay (Ecluse.Core.Registry.Npm) relays through boundedRelay. Each performs the identical fail-closed exchange: run the request, read the body chunk-by-chunk against the budget, and report a bound breach or a transport fault as a typed value rather than an exception. Both live here once so a hardening change to the response bound touches one implementation, not copies that can drift.

Ecosystem-agnostic: this forms no request and speaks no registry protocol, only the bounded read of a Request the caller has already shaped. Request formation, and its own typed fault, stays with the caller.

Synopsis

Bounded response fetch

boundedFetch :: Manager -> Limits -> Request -> IO (Either FetchFault RegistryResponse) Source #

Run a formed Request over the manager and read its response body bounded against the budget, folding every failure into the typed FetchFault channel: a thrown transport exception through classifyTransport as FetchTransport, an over-cap body as FetchBoundExceeded. The transport wrap covers the whole exchange, the bounded body read included, so a connection lost mid-body is a pre-commit fault with a value representation, never a half-read response.

Bounded publish relay

boundedRelay :: Manager -> Limits -> Request -> IO (Either PublishRelayFault PublishRelayResponse) Source #

Run a formed publish Request over the manager and buffer the publication target's response bounded against the budget, folding every failure into the typed PublishRelayFault channel: a thrown transport exception through classifyTransport as RelayTransport, an over-cap body as RelayBoundExceeded. The transport wrap covers the whole exchange, the bounded body read included, so a connection lost mid-body is a pre-commit fault with a value representation, never a half-relayed response. The status the target answered is carried back paired with the buffered body.