ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Queue.Memory

Description

The STM-backed in-memory MirrorQueue: the bounded, best-effort production backend mirroring rolls over to when no ECLUSE_QUEUE__URL is set.

It honours the handle's contract (Ecluse.Core.Queue) with two departures. enqueue drops the newest job past the depth cap, and a receive is final, so nothing redelivers and no delivery carries a lease. Both are safe because the next demand re-enqueues the job.

Synopsis

Bounded in-memory production backend

data MemoryQueueConfig Source #

The bounded in-memory backend's depth cap and idle-poll window. Build it with defaultMemoryQueueConfig for the production poll window.

Constructors

MemoryQueueConfig 

Fields

  • memQueueMaxDepth :: Int

    The maximum number of jobs the queue holds. The config layer enforces a positive cap. An enqueue past it drops the newest job, a safe loss because the next demand re-enqueues.

  • memQueuePollWaitMicros :: Int

    The idle long-poll window in microseconds: how long a receive waits for a job before returning []. The bound keeps the worker's liveness heartbeat advancing on an idle queue.

defaultMemoryQueueConfig :: Int -> MemoryQueueConfig Source #

A MemoryQueueConfig at the production 20s idle-poll window, which sits under workerHeartbeatStaleAfter so an idle poll cannot stall /livez.

newBoundedInMemoryQueue Source #

Arguments

:: MemoryQueueConfig

The depth cap and the idle-poll window.

-> (Int -> IO ())

Invoked on each report-worthy cap-overflow drop with the running total, for the log.

-> IO MirrorQueue 

Build the bounded, best-effort in-memory MirrorQueue. A cold-cache npm ci enqueues thousands of jobs at once, so enqueue sheds past memQueueMaxDepth rather than throwing.

memoryQueueDropReportInterval :: Int Source #

How many cap-overflow drops the bounded in-memory backend absorbs between warning reports. It reports the first drop, then every multiple of this, so a sustained flood cannot spam.