ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Admission.Overflow

Description

Bounded overflow ahead of the metadata gates. Each request keeps its permit and arrival order through retries. Gate signals and sweeper ticks wake requests without request timers.

Synopsis

A gate's line

data Line Source #

Requests one gate turned away, oldest first. Equality identifies the gate of a final refusal.

Instances

Instances details
Eq Line Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Overflow

Methods

(==) :: Line -> Line -> Bool #

(/=) :: Line -> Line -> Bool #

newLine :: IO Line Source #

An empty gate line, with one periodic wake allowed per sweep.

signalLine :: Line -> STM () Source #

Wake the oldest request on the line. A gate runs it in the transaction that frees a place.

The queue

data Overflow Source #

The queue in front of both gates: how many requests wait, how many may, and for how long.

newOverflow :: Deadlines -> Int -> IO Overflow Source #

A queue for the serve slots: eight places for each, and a 0.5 s wait. The deadlines must be swept.

newOverflowTuned :: Deadlines -> Int -> Int -> IO Overflow Source #

Set the cap and the microsecond wait explicitly. Both floor at zero.

overflowWaiting :: Overflow -> IO Int Source #

Requests parked on the gate lines, excluding retries and admitted callbacks.

Waiting for a place

data Attempt a Source #

What one try at the gates came to.

Constructors

Entered a

It got a place, and its action ran.

TurnedAway Line

A gate's room was full, so the request waits on that gate's line.

Expired Line

It took a room place, and the room's wait ran out first.

attemptAfter :: Line -> Either Shed a -> Attempt a Source #

Read a gate's answer, where the line is that gate's.

data Waited a Source #

How a queued request ended.

Constructors

Placed a

It got a place after waiting, and its action ran.

WaitedOut Line

No place freed within the wait, or the room it reached ran out of time.

QueueFull Line

The queue already held its cap, so the request never joined it.

awaitPlace :: MetricsPort -> Overflow -> Line -> IO (Attempt a) -> IO (Waited a) Source #

Queue a request the gate behind the line turned away, and run try each time it wakes, until it gets a place or the wait runs out. Past the cap it answers QueueFull at once.