ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Admission.Weighted

Description

Shared weighted admission for serve slots and publish bytes. A bounded waiting room prevents newcomers from bypassing queued requests. Wake order is not FIFO. The room's wait runs on the deadline sweeper, and each freed place wakes the gate's overflow line.

Synopsis

Documentation

data WeightedAdmission Source #

Capacity and waiting-room state. Only the controller can mutate these fields.

weightedAdmissionWaiting :: WeightedAdmission -> STM Int Source #

Observe committed waiting-room occupancy without changing admission state.

weightedAdmissionLine :: WeightedAdmission -> Line Source #

The line of requests this gate turned away at a full room.

newWeightedAdmission :: Deadlines -> Int -> Int -> Int -> IO WeightedAdmission Source #

Keep capacity verbatim and clamp the room and microsecond wait budget at zero. A positive wait ends on a sweep of the deadlines, so a fixture that never waits one out may leave them unswept.

withWeightedAdmission :: MonadUnliftIO m => AdmissionObservers -> WeightedAdmission -> Int -> m a -> m (Either Shed a) Source #

Hold the supplied weight through the action, or say why the gate turned the request away.

data AdmissionObservers Source #

Admission observers, independent of the telemetry vocabulary.

Constructors

AdmissionObservers 

Fields

  • onQueued :: IO ()

    Runs after a queued request acquires capacity, not when it registers.

  • onShed :: IO ()

    Records a refusal at the door or an expired wait.

  • onInFlightDelta :: Int -> IO ()

    Records signed weight under the acquisition mask.

admissionWaitMicros :: Int Source #

Wait one second, matching the shed response Retry-After hint.