ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Context

Description

Per-request mount wiring, runtime capabilities, and the serve handler monad. Dispatch pairs one MountBinding with ServeRuntime and establishes the ambient katip context. The composition root supplies the runtime capabilities.

Synopsis

Request runtime

data ServeRuntime Source #

Serve capabilities assembled at boot. Both HTTP managers must validate TLS certificates.

Constructors

ServeRuntime 

Fields

Packument-serve dependencies

data PackumentDeps Source #

Mount inputs shared by packument and tarball handlers, resolved at boot.

Constructors

PackumentDeps 

Fields

pdPrivateBaseUrl :: PackumentDeps -> Maybe RegistryUrl Source #

The private URL bound to the host gate. Nothing skips the private fetch.

pdPublicBaseUrl :: PackumentDeps -> RegistryUrl Source #

The public upstream base URL. Reads are anonymous, with no client credential.

pdMirror :: PackumentDeps -> MirrorServePlan Source #

The mirror destination for admitted public artifacts, or no write for a serve-only mount.

pdTarballHostGate :: PackumentDeps -> TarballHostGate Source #

The host gate derived from the mount's upstreams at boot.

tarballHostHonoured :: Origin -> PackumentDeps -> Maybe HostPort -> Maybe HostPort -> Bool Source #

Apply tarballHostAllowed with this mount's inputs for both serving and mirror re-evaluation. A missing authority refuses. Trusted origins bypass only the internal-range block.

Publish-serve dependencies

data PublishDeps Source #

First-party publish inputs. Their presence enables the mount's publish route.

Constructors

PublishDeps 

Fields

The serve action, and the router an adapter supplies

data RouteAction Source #

A matched route's response contract paired with an action that produces only that contract's response type. Dispatch renders the action without knowing an ecosystem's response sum.

Constructors

RouteAction (ResponseContract response) (ResponseAction response) 

data ResponseAction response Source #

A matched request's action, constrained to its route's response contract.

Constructors

AnswerLocally response

A pure value admitted by the route's response contract.

AnswerRefusal (Maybe HelpMessage -> response)

A refusal the route decided, rendered where the mount's help message is known, so a route table carries no configuration of its own.

RunPipeline response (Request -> (response -> IO ResponseReceived) -> Handler ResponseReceived)

A data-plane handler and its pre-commit fallback, both constrained to the route's response type.

type MountRouter = Method -> RequestHeaders -> [Text] -> RouteAction Source #

An ecosystem's whole routing decision over a mount-relative request, from its adapter. The method and the headers are part of the mapping, and segments arrive stripped and decoded.

Mount binding

data MountBinding Source #

Ecosystem wiring under a non-empty prefix, so adding an ecosystem never displaces a root mount.

Constructors

MountBinding 

Fields

Per-request context

data RequestCtx Source #

The context one request is served through: the request runtime paired with the MountBinding the request matched. Dispatch builds it once per request, and Handler reads it through its reader.

Constructors

RequestCtx 

Fields

  • ctxRuntime :: ServeRuntime

    The request runtime: the data-plane managers, the caches and queue, and the recording ports.

  • ctxMount :: MountBinding

    The mount the request matched, carrying its complete ecosystem wiring.

Instances

Instances details
MonadReader RequestCtx Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

The handler monad

data Handler a Source #

Request context over katip's reader-based logging context, shared across concurrent fetches.

Instances

Instances details
MonadIO Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

liftIO :: IO a -> Handler a #

Applicative Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

pure :: a -> Handler a #

(<*>) :: Handler (a -> b) -> Handler a -> Handler b #

liftA2 :: (a -> b -> c) -> Handler a -> Handler b -> Handler c #

(*>) :: Handler a -> Handler b -> Handler b #

(<*) :: Handler a -> Handler b -> Handler a #

Functor Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

fmap :: (a -> b) -> Handler a -> Handler b #

(<$) :: a -> Handler b -> Handler a #

Monad Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

(>>=) :: Handler a -> (a -> Handler b) -> Handler b #

(>>) :: Handler a -> Handler b -> Handler b #

return :: a -> Handler a #

Katip Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

KatipContext Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

MonadUnliftIO Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

withRunInIO :: ((forall a. Handler a -> IO a) -> IO b) -> Handler b #

MonadReader RequestCtx Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

runHandler :: LogEnv -> SimpleLogPayload -> RequestCtx -> Handler a -> IO a Source #

Run a handler with the application's log stream and initial trace-correlation payload.