| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Queue.Buffer
Description
A bounded drop-newest hand-off in front of a MirrorQueue.
The serve path pays an STM write instead of the backend's producer call, which on SQS is an HTTP round trip. At the cap the newest job is dropped, which is safe because mirroring is demand-driven and the next demand re-enqueues it. The drain loop never returns: race it.
Synopsis
- newEnqueueBuffer :: Int -> (Int -> IO ()) -> (Int -> Text -> IO ()) -> MirrorQueue -> IO (MirrorQueue, IO ())
- writeOrDrop :: TBQueue MirrorJob -> TVar Int -> MirrorJob -> STM (Maybe Int)
- reportWorthy :: Int -> Int -> Bool
Buffered producer hand-off
Arguments
| :: Int | Buffer depth: undelivered jobs the hand-off retains before it drops the newest. |
| -> (Int -> IO ()) | Invoked on every drop with the running total. A drop is safe: the next demand re-enqueues. |
| -> (Int -> Text -> IO ()) | Invoked on every backend delivery failure, with the running total and the detail. |
| -> MirrorQueue | The backend whose |
| -> IO (MirrorQueue, IO ()) |
Wrap a bounded drop-newest hand-off in front of a queue, so the serve path pays an STM write and not the backend producer call, an HTTP round trip on SQS. The drain loop never returns, race it.