| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Worker
Description
Mirror worker entry points and supervision. Queued jobs receive current policy and first-party checks before any public fetch. The queue can outlive the deployment's first-party declarations.
Synopsis
- data WorkerRuntime = WorkerRuntime {
- wrQueue :: MirrorQueue
- wrClient :: ExchangeClient
- wrPublicControl :: PublicControl
- 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 {
- wpFirstParty :: PackageName -> Bool
- wpResolveVersion :: StateCharge -> PackageName -> Version -> IO VersionEvaluation
- wpRules :: [PreparedRule]
- wpMinIntegrity :: MinIntegrity
- wpArtifactHostHonoured :: Maybe HostPort -> Bool
- wpEgressUrl :: Text -> Either Text RegistryUrl
- wpArtifact :: AdapterArtifact
- wpPublish :: MirrorPublish
- wpMirrorFormat :: MirrorStateFormat
- wpArtifactLimits :: Limits
- wpMirrorState :: Maybe WorkerMirrorState
- wpNow :: IO UTCTime
- type WorkerPolicies = Map Ecosystem WorkerPolicy
- data WorkerM a
- runWorkerM :: LogEnv -> SimpleLogPayload -> WorkerRuntime -> WorkerM a -> IO a
- workerLoop :: SupervisionPolicy -> WorkerM Void
- processBatch :: [QueueMessage] -> WorkerM ()
- processJob :: MirrorJob -> WorkerM JobOutcome
- data JobOutcome
- data RetryLeg
- data WorkerHeartbeat
- newWorkerHeartbeat :: IO WorkerHeartbeat
- recordPoll :: WorkerHeartbeat -> UTCTime -> IO ()
- lastPoll :: WorkerHeartbeat -> IO (Maybe UTCTime)
- workerJobStepAllowance :: NominalDiffTime
- workerHeartbeatStaleAfter :: NominalDiffTime
- heartbeatHealthy :: UTCTime -> UTCTime -> Maybe UTCTime -> Bool
- data Liveness = Liveness {}
- alwaysLive :: Liveness
- heartbeatLivenessNow :: WorkerHeartbeat -> IO Liveness
Worker runtime
data WorkerRuntime Source #
The effectful backends the mirror worker closes over, read through the WorkerM reader.
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 # | |
Per-ecosystem ingest re-evaluation
data WorkerPolicy Source #
Use the served mount's resolver, rules, and gates for worker admission.
Constructors
| WorkerPolicy | |
Fields
| |
type WorkerPolicies = Map Ecosystem WorkerPolicy Source #
Key bundles by ecosystem. Jobs without a bundle are dropped without publication.
The worker monad
Carry worker runtime and logging context through ReaderT, without mutable request state.
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 # localKatipContext :: (LogContexts -> LogContexts) -> WorkerM a -> WorkerM a # getKatipNamespace :: WorkerM Namespace # localKatipNamespace :: (Namespace -> Namespace) -> WorkerM a -> WorkerM a # | |
| 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 under the caller's logging environment and trace context.
Loop and job processing (exposed for direct testing)
workerLoop :: SupervisionPolicy -> WorkerM Void Source #
The continuous consume loop: long-poll, process, repeat, under the supervision policy. The
heartbeat advances only on progress, so a persistently faulting receive goes stale on /livez.
processBatch :: [QueueMessage] -> WorkerM () Source #
Process one batch sequentially under a lease on every receipt in it. The heartbeat advances
per job, so workerHeartbeatStaleAfter covers one job.
processJob :: MirrorJob -> WorkerM JobOutcome Source #
Recheck current policy before publishing because queue delays are unbounded.
data JobOutcome Source #
A mirror outcome determines acknowledgement, redelivery, or dead-letter handling.
Constructors
| Succeeded | Completion proof covers every expected file and companion, including idempotent redelivery. |
| Dropped Text | A non-retryable rejection. The worker alarms and acknowledges the message. |
| SourceUnavailable Text | The source version object is unavailable. Retire the job separately from a policy denial. |
| DeadLettered Text | A terminal fault sent to the dead-letter handler instead of silently deleted. |
| Retried RetryLeg Text | A transient fault leaves the message unacknowledged and retains the failed leg. |
Instances
| Show JobOutcome Source # | |
Defined in Ecluse.Core.Worker.Job Methods showsPrec :: Int -> JobOutcome -> ShowS # show :: JobOutcome -> String # showList :: [JobOutcome] -> ShowS # | |
| Eq JobOutcome Source # | |
Defined in Ecluse.Core.Worker.Job | |
The failed leg determines whether the worker resets queue visibility.
Constructors
| BeforePublish | A failure before publication keeps the lease until redelivery. |
| AfterPublish | A transient publication failure releases the message for immediate redelivery. |
Liveness
data WorkerHeartbeat Source #
Worker progress and its startup allowance, separate from HTTP readiness.
newWorkerHeartbeat :: IO WorkerHeartbeat Source #
Build a fresh WorkerHeartbeat with no poll yet recorded (lastPoll is
Nothing until the worker's first successful receive).
recordPoll :: WorkerHeartbeat -> UTCTime -> IO () Source #
Stamp the heartbeat with the given instant, recording a unit of worker progress.
The worker calls it through recordWorkerProgress.
lastPoll :: WorkerHeartbeat -> IO (Maybe UTCTime) Source #
The instant of the worker's last recorded progress, a successful poll or a completed
job, or Nothing before its first.
workerJobStepAllowance :: NominalDiffTime Source #
How long one long job step may run: uploading the largest artifact the memory plan admits (512 MiB) over a 2 MiB-per-second link. Renewing a receipt's visibility never extends it.
workerHeartbeatStaleAfter :: NominalDiffTime Source #
Startup and progress allowance: a fetch and a publish of that largest artifact plus a minute, so a slow job never restarts the process.
heartbeatHealthy :: UTCTime -> UTCTime -> Maybe UTCTime -> Bool Source #
Judge progress at now, using startup time only until the first successful progress.
What /livez answers from: the health verdict, plus the instant the checked loop last
recorded progress so an orchestrator can judge staleness rather than only pass or fail.
Constructors
| Liveness | |
Fields
| |
alwaysLive :: Liveness Source #
The verdict of a role with no background loop to stall: live, with nothing to report.
heartbeatLivenessNow :: WorkerHeartbeat -> IO Liveness Source #
Read the worker heartbeat and judge it against the current wall clock, keeping the
instant judged. Both the embedded and the dedicated worker answer /livez through this.