ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Pipeline.Tarball.Relay

Description

Request shaping and response classification for artifact relays. Response judgements precede the client response commit.

Synopsis

Serve mode

data ArtifactServe Source #

The artifact serve mode, threaded through the artifact path so GET and HEAD share one gate and one upstream-request construction.

Constructors

ServeFull

A GET: stream the artifact body through, enqueuing a mirror job on a public admit.

ServeHead

A HEAD: probe upstream as a HEAD and relay the headers with no body. It serves no bytes, so it mirrors nothing.

Shaping the upstream artifact request

withMethod :: ArtifactServe -> Request -> Request Source #

Tag an upstream artifact request with the serve mode's method. ServeFull keeps the GET.

withValidators :: RequestHeaders -> Request -> Request Source #

Relay the client's conditional validators onto an upstream artifact request, so upstream can answer a 304 Not Modified instead of resending an unchanged body.

Relaying the upstream response

relayUpstreamWhen :: ArtifactServe -> Manager -> ProgressFloor -> Request -> (Status -> Bool) -> (Status -> ResponseHeaders -> IO (Status, ResponseHeaders, verdict)) -> RelayResponder response -> IO (Maybe (verdict, response)) Source #

Relay an upstream artifact response in the serve mode. Both modes keep the same recoverable-miss and committed split, so a HEAD falls through a private miss as a GET does.

acceptArtifact :: Status -> Bool Source #

A successful artifact response, including a matching conditional validator.

relayUnjudged :: Status -> ResponseHeaders -> IO (Status, ResponseHeaders, ()) Source #

The trusted leg's pre-commit relay. It judges nothing, so the private path pays no header scan for an anomaly only the public leg can have.

relayJudged :: Status -> ResponseHeaders -> IO (Status, ResponseHeaders, RelayVerdict) Source #

The public leg's pre-commit relay. The verdict is decided before any body moves, so a committed relay always carries exactly one.

Judging the public relay

data RelayVerdict Source #

What the public leg relayed, judged at relay time from the status and headers alone.

Constructors

RelayedArtifact

A success whose headers look like the admitted artifact. A relayed 304 counts.

RelayedOddShape Text

A success that does not look like an artifact. Carries a bounded reason.

RelayedNonSuccess Status

A non-success passed through verbatim. Carries the status.

relayVerdict :: Status -> ResponseHeaders -> RelayVerdict Source #

Judge one public relay from its status and headers alone.

observeRelayAnomaly :: KatipContext m => MetricsPort -> PackageName -> Version -> RelayVerdict -> m () Source #

Observe one public-relay verdict. An anomaly counts on the bounded ecluse.serve.relay.anomalies metric, and the unbounded detail stays on the log line.