ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Pipeline.Origin

Description

Resolve caller-authorised private metadata and anonymous public metadata. Access refusals, absent packages and unread origins retain distinct outcomes, and an unread origin keeps the cause that sets a private refusal's status.

Synopsis

The per-origin outcome

data OriginResult Source #

One origin's contribution, access refusal, identity mismatch, or absence.

Constructors

OriginBudgetExceeded LimitError

The request-wide observed read bound was crossed.

OriginResolved Manifest

A packument that decoded and whose self-reported name matched the request.

OriginAuthorisationFailure Int

An explicit upstream access refusal, retaining its 401 or 403. A public one refuses a listing with nothing admitted as an invalid reply, because the public read is anonymous.

OriginNameMismatch

An invalid package identity. A public one contributes a 502 when no valid origin remains, and a private one refuses the request.

OriginNotFound

The origin answered 404, so it holds no such package. It degrades to no contribution.

OriginUnresolved ReadFailure

The origin was not read, for this cause. A private one refuses the request. A public one contributes nothing, and when no version survives its cause refuses the listing as a private one would.

OriginCooling RetryAfter

Public reads are suspended until the authority cooldown expires.

OriginAbsent

An unconfigured origin contributes neither metadata nor an availability failure.

data OriginMiss Source #

Distinguish a settled absence from an unread origin that a retry may resolve.

Constructors

MissAbsent

The origin holds no such package, or the mount configures no such origin.

MissUnresolved ReadFailure

The origin was not read, so nothing yet says whether it holds the package.

Instances

Instances details
Show OriginMiss Source # 
Instance details

Defined in Ecluse.Core.Server.Pipeline.Origin

Eq OriginMiss Source # 
Instance details

Defined in Ecluse.Core.Server.Pipeline.Origin

data ReadFailure Source #

Why a read failed, which sets the status of a refusal it causes.

Constructors

ReadUnavailable (Maybe RetryAfter)

503: a transport failure, a timeout, a 5xx or a 429, with any delay the origin asked for.

ReadInvalid

502: an unfollowed 3xx, another unexpected status, a name mismatch, an undecodable document or a bound breach.

Instances

Instances details
Show ReadFailure Source # 
Instance details

Defined in Ecluse.Core.Server.Pipeline.Origin

Eq ReadFailure Source # 
Instance details

Defined in Ecluse.Core.Server.Pipeline.Origin

originManifest :: OriginResult -> Maybe Manifest Source #

The resolved manifest an origin contributed, if any.

originMiss :: OriginResult -> Maybe OriginMiss Source #

The miss an origin yielded, or Nothing when it contributed a document or an access refusal.

Why a read failed

statusReadFailure :: Int -> Maybe RetryAfter -> ReadFailure Source #

Classify an unsuccessful status that is neither a 404 nor an access refusal.

fetchReadFailure :: FetchFault -> ReadFailure Source #

Classify a failed exchange. An unformable URL sent no request, and keeps the unavailable refusal.

metadataReadFailure :: MetadataError -> Maybe ReadFailure Source #

The cause of a failed metadata read, or Nothing for an access refusal or a settled absence.

readFailureRefusal :: Text -> Text -> ReadFailure -> ServeDecision Source #

The refusal a failed read of the named upstream renders: 503 under the given words with its delay, or 502 naming that upstream for an invalid reply.

Fetching the two origins

fetchPrivateOriginObserved :: (Int -> IO ()) -> PackumentDeps -> ServeRuntime -> ChargePart -> Maybe ClientCredential -> PackageName -> Handler OriginResult Source #

Read caller-authorised private metadata without caching and observe every incoming full-read chunk.

fetchPublicOriginObserved :: (Int -> IO ()) -> PackumentDeps -> ServeRuntime -> MemoryTicket -> ChargePart -> PackageName -> Handler OriginResult Source #

Cache anonymous public metadata and observe shared-read leader chunks. Cache consumers retain their own document accounting.

withPublicMetadata :: ServeRuntime -> PackumentDeps -> MemoryTicket -> PackageName -> Version -> (IO (Either MetadataError VersionRead) -> Handler a) -> Handler a Source #

Reserve each consumer's selected facts. Serving consumers never retain the cached source row.

withPrivateMetadataClient :: ServeRuntime -> PackumentDeps -> Maybe MemoryTicket -> BaseRequest -> Maybe ClientCredential -> (MetadataClient -> IO a) -> Handler a Source #

Bypass shared caching so the private upstream authorises each caller's credential. Static lookups can omit the ticket. Native workspace admission requires one.

One origin's coordinates

mountOrigin :: PackumentDeps -> ExchangeClient -> BaseRequest -> Maybe ClientCredential -> OriginClient Source #

Build an origin with the mount's response bound and the caller-selected transport and credential.

publicSource :: PackumentDeps -> Source Source #

The public origin's cache source, keyed by its base URL.