ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Rules.Outage.Internal

Description

The outage state machine behind Ecluse.Core.Rules.Outage: what one evaluation saw, the state it folds into, the reports that fold emits, and the record of admissions already logged.

Importing this module opts out of the public surface's stability promises. It exists so a spec can drive the fold directly, without a clock or a shared cell.

Synopsis

What one evaluation saw

data SourceHealth Source #

What one rule's evaluation established about the source it reads.

Constructors

SourceAnswered Text

The named rule consulted its source, whatever it decided.

SourceUnavailable Text Reason

The named rule could not consult its source, for the given cause.

The transition machine

data OutageState Source #

One source's outage state. It carries no Eq: comparing two states walks the logged record, so a change is decided by the fold that made it, never by comparison.

Instances

Instances details
Show OutageState Source # 
Instance details

Defined in Ecluse.Core.Rules.Outage.Internal

data OngoingOutage Source #

An outage names every rule still unable to consult the source, so a rule whose breaker is still open keeps the outage open after a sibling's probe succeeds.

Constructors

OngoingOutage 

Fields

Instances

Instances details
Show OngoingOutage Source # 
Instance details

Defined in Ecluse.Core.Rules.Outage.Internal

data OutageReport Source #

The three reports an outage produces, each carrying what an operator line needs.

Constructors

OutageBegan Text Reason

The first rule unable to consult the source, with its cause.

OutageContinues UTCTime (Map Text Reason)

The reminder: when the outage began, and every rule still unable, with its latest cause.

OutageRecovered UTCTime

Every rule consults the source again. Carries when the outage began.

data OutageStep Source #

What one reading did to the state. The change flag is what decides a commit.

Constructors

OutageStep 

Fields

stepOutage :: NominalDiffTime -> UTCTime -> SourceHealth -> OutageState -> OutageStep Source #

Fold one reading into the state at now. A transition reports at once, and an outage that continues reports again only once period has passed since its last report.

Evidence logged during an outage

data AdmissionIdentity Source #

What identifies one admission's evidence line: the package, the version, and the checks it skipped.

Constructors

AdmissionIdentity 

Fields

data LoggedAdmissions Source #

The admissions logged during one outage, oldest first, so the record can evict in arrival order once it reaches its cap.

noLoggedAdmissions :: LoggedAdmissions Source #

An outage that has logged nothing yet.

loggedAdmissionCap :: Int Source #

How many identities one outage remembers: a few megabytes resident per ecosystem at the cap, past which an outage over a large mirror repeats a line only once its oldest identities age out.

noteLogged :: Int -> AdmissionIdentity -> LoggedAdmissions -> (LoggedAdmissions, Bool) Source #

Decide whether the gate logs this admission, and the record after it. A repeat is skipped, a new identity is recorded, and the oldest identity is evicted once the record holds cap.

admissionLogged :: Int -> AdmissionIdentity -> OutageState -> (OutageState, Bool) Source #

noteLogged over the source's state. A healthy source has no outage to remember the admission under, so the gate logs it and the state is unchanged.

Where the state lives

data OutageStore Source #

Where one source's outage state lives: a plain read, and a fold committed as one unit.

Constructors

OutageStore 

Fields