ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

Ecluse.Runtime.Env

Description

The composition root: the single record every effectful component is reached through, and the one place backend choice is resolved. Each handle it holds is an opaque record of functions whose closures already capture their backend's private state, so no cloud SDK appears here and nothing downstream inspects which backend it got. That is what keeps an adapter from importing back into this module. It also carries the http-client Manager the data plane shares. The single-process proxy and the split deployment both wire up here and nowhere else. Consumers read it through a projection: serveRuntimeOf per request, workerRuntimeOf for the worker.

Synopsis

Composition root

data Env Source #

The composition-root record from which the whole effectful shell is reached.

Constructors

Env 

Fields

newEnvWithAdmission :: ServeAdmission -> MemoryMeter -> MirrorQueue -> Manager -> Manager -> MetadataCache -> LogEnv -> Telemetry -> WorkerHeartbeat -> IO Env Source #

Assemble an Env from its built handles and the two data-plane Managers, one per origin. The caller supplies each handle and owns its lifetime, so assembly opens no socket itself.

withEnvWithAdmission :: MonadIO m => ServeAdmission -> MemoryMeter -> MirrorQueue -> Manager -> Manager -> MetadataCache -> LogEnv -> Telemetry -> WorkerHeartbeat -> (Env -> m a) -> m a Source #

Assemble an Env and run an action in its scope, the scope the server and worker run in. The root borrows every resource it holds, so it has nothing to release and needs no bracket.

Runtime projections

serveRuntimeOf :: Env -> ServeRuntime Source #

Project the ServeRuntime the serve path closes over, built per request at dispatch. The core pipeline reads its backends through it without depending on this application Env.

workerRuntimeOf :: WorkerPolicies -> Env -> WorkerRuntime Source #

Project the WorkerRuntime the mirror worker closes over. WorkerPolicies is an argument because it derives from the served mounts, and the worker re-runs it through the serve gate.

Worker heartbeat (re-exported from Ecluse.Core.Worker)