| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Worker.Types
Synopsis
- data WorkerRuntime = WorkerRuntime {
- wrQueue :: MirrorQueue
- wrRegistry :: RegistryClient
- wrManager :: Manager
- wrHeartbeat :: WorkerHeartbeat
- wrMetrics :: WorkerMetricsPort
- wrTracing :: WorkerTracingPort
- wrInjectTraceContext :: forall (m :: Type -> Type) a. (KatipContext m, MonadIO m) => m a -> m a
- wrPolicies :: WorkerPolicies
- data WorkerPolicy = WorkerPolicy {
- wpResolveVersion :: PackageName -> Version -> IO VersionEvaluation
- wpRules :: [PreparedRule]
- wpNow :: IO UTCTime
- type WorkerPolicies = Map Ecosystem WorkerPolicy
- data WorkerM a
- runWorkerM :: LogEnv -> SimpleLogPayload -> WorkerRuntime -> WorkerM a -> IO a
Documentation
data WorkerRuntime Source #
The runtime backends the mirror worker is closed over: exactly the effectful
capabilities the consume loop needs to poll, fetch, verify, publish, and record. A
record of concrete handles and abstract ports (the Handle pattern), assembled by the
composition root (workerRuntimeOf) and read by the loop through the
WorkerM reader.
The mirror queue is the demand-driven hand-off the loop consumes; the publish-side
registry client writes approved artifacts to the mirror target; the untrusted
data-plane manager fetches the artifact bytes (the validating TLS manager, over an
https-only dist.tarball); the heartbeat is the loop's liveness surface. The metric and
tracing ports are the abstract recording interfaces (Ecluse.Core.Telemetry.Record,
Ecluse.Core.Telemetry.Span); the application supplies their OpenTelemetry-backed
implementations, so the loop records without naming a telemetry backend. There is no log
field: the loop logs through the ambient katip context the entry point establishes.
Constructors
| WorkerRuntime | |
Fields
| |
Instances
| MonadReader WorkerRuntime WorkerM Source # | |
Defined in Ecluse.Core.Worker.Types Methods ask :: WorkerM WorkerRuntime # local :: (WorkerRuntime -> WorkerRuntime) -> WorkerM a -> WorkerM a # reader :: (WorkerRuntime -> a) -> WorkerM a # | |
data WorkerPolicy Source #
The per-ecosystem re-evaluation bundle the worker re-runs current policy through before it mirrors a job: a resolver that fetches and projects the single version's metadata, the prepared rule set, and the wall-clock the age rules read.
The resolver is the shared single-version fetch-and-project
(fetchVersionDetails over the guarded public origin,
wired by the composition root), and the rules are the same prepared rules the serve
path gates with, so the worker's ingest decision and the serve-time decision run one
codepath and any per-source breaker state is shared, never forked.
Constructors
| WorkerPolicy | |
Fields
| |
type WorkerPolicies = Map Ecosystem WorkerPolicy Source #
The worker's per-ecosystem re-evaluation bundles, keyed by the ecosystem a job's
package belongs to (pkgEcosystem). Built once at boot and shared
with the serve mounts; a job whose ecosystem is absent here is fail-closed (dropped), never
mirrored unvetted.
The mirror worker's monad: a reader over the WorkerRuntime layered on katip's
logging context.
A newtype over so its instances are
this module's to control and call sites name one concrete monad. The derived instances
give reader access to the runtime (ReaderT WorkerRuntime (KatipContextT IO)MonadReader WorkerRuntime), arbitrary effects
(MonadIO), the unlift capability (MonadUnliftIO) the loop's tryAny and the per-job
span bracket need, and the katip classes (Katip, KatipContext) so a structured log
call composes through the ambient context the entry point establishes.
The katip base is a reader, never a StateT, so the logging context behaves correctly
across the loop (see docs/architecture/technology-stack.md → "Key Decisions").
Instances
| MonadIO WorkerM Source # | |
Defined in Ecluse.Core.Worker.Types | |
| Applicative WorkerM Source # | |
| Functor WorkerM Source # | |
| Monad WorkerM Source # | |
| Katip WorkerM Source # | |
| KatipContext WorkerM Source # | |
Defined in Ecluse.Core.Worker.Types Methods getKatipContext :: WorkerM LogContexts Source # localKatipContext :: (LogContexts -> LogContexts) -> WorkerM a -> WorkerM a Source # getKatipNamespace :: WorkerM Namespace Source # localKatipNamespace :: (Namespace -> Namespace) -> WorkerM a -> WorkerM a Source # | |
| MonadUnliftIO WorkerM Source # | |
Defined in Ecluse.Core.Worker.Types | |
| MonadReader WorkerRuntime WorkerM Source # | |
Defined in Ecluse.Core.Worker.Types Methods ask :: WorkerM WorkerRuntime # local :: (WorkerRuntime -> WorkerRuntime) -> WorkerM a -> WorkerM a # reader :: (WorkerRuntime -> a) -> WorkerM a # | |
runWorkerM :: LogEnv -> SimpleLogPayload -> WorkerRuntime -> WorkerM a -> IO a Source #
Run a WorkerM against the WorkerRuntime and the katip logging environment and
initial context the entry point supplies, yielding the underlying IO action. This is
the boundary where the worker's WorkerM code is discharged to IO.
The LogEnv (the structured-log scribes) and the initial context payload are passed in
rather than read from the runtime, so the application owns the log stream and the
trace-correlation dd enrichment: it resolves the dd identity and hands it here as the
initial context, so every line the loop emits carries dd. The loop narrows the
namespace with katip's combinators on top as it logs.