| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data SourceHealth
- data OutageState
- data OngoingOutage = OngoingOutage {}
- data OutageReport
- data OutageStep = OutageStep {}
- stepOutage :: NominalDiffTime -> UTCTime -> SourceHealth -> OutageState -> OutageStep
- data AdmissionIdentity = AdmissionIdentity {}
- data LoggedAdmissions
- noLoggedAdmissions :: LoggedAdmissions
- loggedAdmissionCap :: Int
- noteLogged :: Int -> AdmissionIdentity -> LoggedAdmissions -> (LoggedAdmissions, Bool)
- admissionLogged :: Int -> AdmissionIdentity -> OutageState -> (OutageState, Bool)
- data OutageStore = OutageStore {
- readOutage :: IO OutageState
- commitOutage :: forall a. (OutageState -> (OutageState, a)) -> IO a
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. |
Instances
| Show SourceHealth Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods showsPrec :: Int -> SourceHealth -> ShowS # show :: SourceHealth -> String # showList :: [SourceHealth] -> ShowS # | |
| Eq SourceHealth Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal | |
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.
Constructors
| Healthy | |
| Outage OngoingOutage |
Instances
| Show OutageState Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods showsPrec :: Int -> OutageState -> ShowS # show :: OutageState -> String # showList :: [OutageState] -> ShowS # | |
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
| Show OngoingOutage Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods showsPrec :: Int -> OngoingOutage -> ShowS # show :: OngoingOutage -> String # showList :: [OngoingOutage] -> ShowS # | |
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. |
Instances
| Show OutageReport Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods showsPrec :: Int -> OutageReport -> ShowS # show :: OutageReport -> String # showList :: [OutageReport] -> ShowS # | |
| Eq OutageReport Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal | |
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 | |
Instances
| Show AdmissionIdentity Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods showsPrec :: Int -> AdmissionIdentity -> ShowS # show :: AdmissionIdentity -> String # showList :: [AdmissionIdentity] -> ShowS # | |
| Eq AdmissionIdentity Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods (==) :: AdmissionIdentity -> AdmissionIdentity -> Bool # (/=) :: AdmissionIdentity -> AdmissionIdentity -> Bool # | |
| Ord AdmissionIdentity Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods compare :: AdmissionIdentity -> AdmissionIdentity -> Ordering # (<) :: AdmissionIdentity -> AdmissionIdentity -> Bool # (<=) :: AdmissionIdentity -> AdmissionIdentity -> Bool # (>) :: AdmissionIdentity -> AdmissionIdentity -> Bool # (>=) :: AdmissionIdentity -> AdmissionIdentity -> Bool # max :: AdmissionIdentity -> AdmissionIdentity -> AdmissionIdentity # min :: AdmissionIdentity -> AdmissionIdentity -> AdmissionIdentity # | |
data LoggedAdmissions Source #
The admissions logged during one outage, oldest first, so the record can evict in arrival order once it reaches its cap.
Instances
| Show LoggedAdmissions Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods showsPrec :: Int -> LoggedAdmissions -> ShowS # show :: LoggedAdmissions -> String # showList :: [LoggedAdmissions] -> ShowS # | |
| Eq LoggedAdmissions Source # | |
Defined in Ecluse.Core.Rules.Outage.Internal Methods (==) :: LoggedAdmissions -> LoggedAdmissions -> Bool # (/=) :: LoggedAdmissions -> LoggedAdmissions -> Bool # | |
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
| |