ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

Ecluse.Runtime.Server.Middleware

Description

The front door's cross-cutting middleware pieces and the control-plane health endpoints: the drain-aware going-away header, the per-request timeout knob, and the /livez / /readyz probe application. Ecluse.Runtime.Server's serverMiddleware composes the pieces around the proxy Application; its dispatch answers the probes through probeApplication. The request-body cap is not here: it is a route concern, enforced at the read site by the only body-consuming route (publish).

Synopsis

Drain-aware going-away header

goingAwayMiddleware :: DrainSignal -> Middleware Source #

While the instance is draining, stamp Connection: close on every response so a keep-alive client (or a mesh connection pool) does not reuse the socket on a closing instance; while serving, pass responses through untouched. The flag is read per-response -- the same one-way DrainSignal the readiness probe observes -- so the header appears the moment the drain begins and on every response thereafter.

Per-request timeout

timeoutSeconds :: Int Source #

The per-request timeout, in seconds. Generous enough for a large packument fetch, bounded so a stuck upstream cannot pin a handler indefinitely.

Control-plane health probes

probeApplication :: DrainSignal -> IO Bool -> IO Bool -> Application Source #

The control-plane health probes, answered above any mount: /livez from the injected liveness check (the worker-heartbeat arm folded in by the caller), /readyz from the drain signal ANDed with the composition root's startup gate, and any other unmounted path as the neutral 404.

Neutral response shapes

jsonResponse :: Status -> LByteString -> Response Source #

A JSON response with the given status and body, tagged application/json.