Files
mesh-delivery/modules/mesh-delivery-checker/internal/check/names.go
T

90 lines
3.9 KiB
Go

package check
import (
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
"git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshwatchdogs"
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdelivery"
checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker"
)
// The holders and buckets the checker names. No contract names a holder (novox/hq ADR 0625 §4, ADR 0634 §1), so these are its
// own constants, each a state of a seat (the seat's state name beside the holder's module name) and each declared in its
// manifest (module.json: its own states, its `reads`); a unit row checks them against the manifest (TestTheNamesAreTheManifests).
const (
// CheckerModule is this part's module; its states verdicts, kept, owed and previews are the seat mesh-delivery-checker's.
CheckerModule = "mesh-delivery-checker"
CheckerVerdictsBucket = CheckerModule + "_" + checker.StateVerdicts
CheckerKeptBucket = CheckerModule + "_" + checker.StateKept
CheckerOwedBucket = CheckerModule + "_" + checker.StateOwed
PreviewsBucket = CheckerModule + "_" + checker.StatePreviews
// GateModule holds the seat mesh-delivery's states source and turns, which the checker reads (reads: mesh-delivery-gate.source,
// mesh-delivery-gate.turns).
GateModule = "mesh-delivery-gate"
SourceBucket = GateModule + "_" + meshdelivery.StateSource
TurnsBucket = GateModule + "_" + meshdelivery.StateTurns
// IndexerModule holds the seat mesh-catalog's states, which the checker follows by their views (consumes:
// mesh-delivery-indexer.views.*).
IndexerModule = "mesh-delivery-indexer"
CandidatesBucket = IndexerModule + "_" + meshcatalog.StateCandidates
ModulesBucket = IndexerModule + "_" + meshcatalog.StateModules
ManifestsBucket = IndexerModule + "_" + meshcatalog.StateManifests
IndexerPredefinedState = meshcatalog.StatePredefined
// WatchmanModule holds the seat mesh-watchdogs' presence (reads: mesh-delivery-watchman.presence).
WatchmanModule = "mesh-delivery-watchman"
PresenceBucket = WatchmanModule + "_" + meshwatchdogs.StatePresence
// HaveBucket is the node-engine's state have (reads: node-engine.have); a node's own key ends in HaveNodeWord.
HaveBucket = "node-engine_" + nodeengine.StateHave
HaveNodeWord = "node"
// compositionWaits is the state of the assigner's composition answer that waits for what it composes from.
compositionWaits = "waits"
)
// FailedFirst names what failed: a test (its package and name) or a machine, with the words of the failure. It is the shape of
// the verdict's `failed` and of each entry of its `failures` (the seat's two types of it have the same fields), so the check
// judges with one and converts at the verdict's edge (failureItems, failedList).
type FailedFirst = checker.VerdictsByGroupHeadsValueFailed
// failedOf is the first failure a verdict names: the zero value of a verdict that names none.
func failedOf(v checker.VerdictsByGroupHeadsValue) FailedFirst {
if v.Failed == nil {
return FailedFirst{}
}
return *v.Failed
}
// tookOf is the time of each part of a check a verdict names: the zero value of a verdict that names none.
func tookOf(v checker.VerdictsByGroupHeadsValue) checker.VerdictsByGroupHeadsValueTook {
if v.Took == nil {
return checker.VerdictsByGroupHeadsValueTook{}
}
return *v.Took
}
func failureItems(list []FailedFirst) []checker.VerdictsByGroupHeadsValueFailuresItem {
if list == nil {
return nil
}
out := make([]checker.VerdictsByGroupHeadsValueFailuresItem, len(list))
for i, f := range list {
out[i] = checker.VerdictsByGroupHeadsValueFailuresItem(f)
}
return out
}
func failedList(items []checker.VerdictsByGroupHeadsValueFailuresItem) []FailedFirst {
if items == nil {
return nil
}
out := make([]FailedFirst, len(items))
for i, f := range items {
out[i] = FailedFirst(f)
}
return out
}