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 method and whether a public admit enqueues a mirror job.

Constructors

ServeFull

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

ServeHead

Probe with HEAD without streaming bytes or enqueuing a mirror job.

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 #

Forward conditional validators so upstream can answer 304.

Relaying the upstream response

relayUpstreamResult :: ArtifactServe -> ExchangeClient -> ProgressFloor -> Request -> (Status -> Bool) -> (Status -> ResponseHeaders -> IO (Status, ResponseHeaders, verdict)) -> RelayResponder response -> IO (UpstreamResult (verdict, response)) Source #

Relay in the serve mode, preserving an upstream rejection or transport failure.

relayPublicResult :: PublicControl -> PublicReadKind -> ArtifactServe -> ExchangeClient -> ProgressFloor -> Request -> (Status -> Bool) -> (Status -> ResponseHeaders -> IO (Status, ResponseHeaders, verdict)) -> RelayResponder response -> IO (UpstreamResult (verdict, response)) Source #

Relay a public artifact or companion after shared authority admission.

acceptArtifact :: Status -> Bool Source #

A successful artifact response, including a matching conditional validator.

acceptPrivateArtifact :: Status -> Bool Source #

Private authorisation failures commit a local refusal instead of allowing public fallback.

privateArtifactResponder :: (Status -> IO result) -> (response -> result) -> RelayResponder response -> RelayResponder result Source #

Replace private access refusals without invoking either upstream responder.

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

Forward private headers without the public leg's anomaly scan.

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

Judge public headers before committing the response.

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 #

Count bounded anomaly classes and log their unbounded detail.