| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Server.Admission.Weighted
Description
The weighted door/wait/shed admission core behind serve admission (Ecluse.Core.Server.Admission) and byte-weighted publish admission (Ecluse.Core.Server.Admission.Bytes).
A handle caps the aggregate weight held at once and keeps a bounded room of waiters. Capacity
is taken directly only when the room is empty, so a newcomer never jumps a non-empty room,
though wake order within the room is not FIFO. The wait budget equals the shed path's
Retry-After: 1 hint, so nothing is refused faster than the client was told to wait.
Synopsis
- data WeightedAdmission
- newWeightedAdmission :: Int -> Int -> Int -> IO WeightedAdmission
- withWeightedAdmission :: MonadUnliftIO m => AdmissionObservers -> WeightedAdmission -> Int -> m a -> m (Maybe a)
- data AdmissionObservers = AdmissionObservers {}
- admissionWaitMicros :: Int
Documentation
data WeightedAdmission Source #
The bounded handle's mutable state and its tuning. The constructor stays hidden so only the checked acquire, wait, and release operations can mutate it.
newWeightedAdmission :: Int -> Int -> Int -> IO WeightedAdmission Source #
Allocate a handle over a capacity, a waiter-room bound, and a wait budget (microseconds). The capacity is verbatim, the wrapper owning that policy, and the other two floor at zero.
withWeightedAdmission :: MonadUnliftIO m => AdmissionObservers -> WeightedAdmission -> Int -> m a -> m (Maybe a) Source #
Run an action holding the given weight. Nothing is a shed, at a full room or an expired
wait. The weight is used as given, and released on every exit path, cancellation included.
data AdmissionObservers Source #
The metric hooks the door/wait/release bracket calls. The shared machine owns no telemetry vocabulary, so each instance records under its own signals.
Constructors
| AdmissionObservers | |
Fields
| |
admissionWaitMicros :: Int Source #
The wait budget (microseconds) before a busy acquisition is shed, deliberately equal to
the shed path's Retry-After: 1 hint, so nothing is refused faster than the client was told.