ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Admission.Budget

Description

The arithmetic of the metadata memory budget: what a byte count costs, how many steps cover a shortfall, and which request the meter lets move. Ecluse.Core.Server.Admission.Meter applies these decisions inside its transactions.

Synopsis

Charges

scaleCharge :: Int -> Int -> Int Source #

The charge for a byte count, rounded up, so a non-empty read never costs nothing.

roundUpToStep :: Int -> Int -> Int Source #

The smallest whole number of steps that covers a shortfall, in bytes.

Decisions

data MeterView Source #

What a meter transaction reads before it decides.

Constructors

MeterView 

Fields

Instances

Instances details
Show MeterView Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Budget

Eq MeterView Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Budget

data EntryGate Source #

The gate's answer to a new request.

Constructors

EntryAdmit

The entry step fits now.

EntryQueue

Wait for the step, up to the admission wait.

EntryRefuse

The waiting room is full: shed at once.

Instances

Instances details
Show EntryGate Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Budget

Eq EntryGate Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Budget

entryDecision :: MeterView -> Int -> Int -> Int -> EntryGate Source #

New work takes its entry step only when it fits, nobody queued before it, and no started read is paused. A paused read always has the prior claim on freed memory.

entryReady :: MeterView -> Int -> Bool Source #

Whether a queued request may take its entry step now.

data GrowthGate Source #

The answer to a started request that needs more bytes.

Constructors

GrowWithin

The step fits within the budget.

GrowOnToken

The step does not fit, but it serves the ticket that holds the overdraw token.

GrowTakeToken

The step does not fit, the token is free, and this charge serves the oldest paused ticket.

GrowWait

Pause until memory frees.

Instances

Instances details
Show GrowthGate Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Budget

Eq GrowthGate Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Budget

growthDecision :: MeterView -> IntSet -> Int -> GrowthGate Source #

A step that fits proceeds. Past the budget, only work serving the token holder moves, or with a free token, work serving the oldest paused ticket. served: the charging ticket and those waiting on it.