package view import ( "fmt" "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/sdk/trunk" "git.novox.be/novox/mesh-sdk/go/keys" ) // The holders, states and buckets the view names, taken from its own manifest (module.json: its `reads`, `invokes` and // `consumes`); a unit row checks them against it (TestTheNamesAreTheManifests). No contract names a holder (novox/hq // ADR 0625 §4, ADR 0634 §1). The indexer's module and its reads are the catalog client's. const ( IndexerModule = "mesh-delivery-indexer" AssignerModule = "mesh-delivery-assigner" // ProvisionsRead is the seat mesh-provisioner's state provisions, as the manifest's `reads` names it. ProvisionsRead = "mesh-provisioner.provisions" WatchmanModule = "mesh-delivery-watchman" GateModule = "mesh-delivery-gate" TellerModule = "mesh-delivery-teller" VaultModule = "mesh-vault" EngineModule = "node-engine" // The indexer's states the view reads. ModulesBucket = IndexerModule + "_modules" CandidatesBucket = IndexerModule + "_candidates" TakenBucket = IndexerModule + "_taken" PackagesState = "packages" PackagesBucket = IndexerModule + "_" + PackagesState // IndexerPredefinedState and IndexerConfigCandidatesState are the indexer's states of the foundation's predefined list // and of the config candidates; PredefinedListKey is the one key of the first. IndexerPredefinedState = "predefined" PredefinedListKey = "list" IndexerConfigCandidatesState = "config-candidates" // The assigner's states. AssignmentsState = "assignments" AssignmentsBucket = AssignerModule + "_" + AssignmentsState AssignerWantsBucket = AssignerModule + "_wants" AssignerAsksBucket = AssignerModule + "_asks" // The gate's and the teller's states. SourceBucket = GateModule + "_source" AsksBucket = GateModule + "_asks" AnswersBucket = TellerModule + "_answers" // The watchman's and the node-engine's states. PresenceBucket = WatchmanModule + "_presence" StuckBucket = WatchmanModule + "_stuck" HaveBucket = EngineModule + "_have" // StepsState is the state of steps each build module keeps (reads: mesh-build-.steps), whose pauses are buildstep's. StepsState = "steps" // The revisions each of those states keeps per key. AsksHistory = 5 AnswersHistory = 5 AssignerAsksHistory = 5 // SignersRead is the vault's state of signing keys as a manifest's `reads` names it, SignersKeyKey its one key. SignersRead = VaultModule + ".signers" SignersKeyKey = "key" ) // CandidatesKey is the key, in the indexer's candidates, of a group: the group name as a key part. ParseCandidatesKey is its inverse. func CandidatesKey(group string) (string, error) { if group == "" { return "", fmt.Errorf("view: the group name is empty") } return keys.EscapeName(group), nil } // ParseCandidatesKey is the inverse of CandidatesKey. func ParseCandidatesKey(key string) (string, error) { group, err := keys.UnescapeName(key) if err != nil || group == "" { return "", fmt.Errorf("view: %q is not a candidates key: %v", key, err) } return group, nil } // PackagesKey is the key, in the indexer's packages, of a mesh Go module (its module path): the path as a key part. It refuses // a path that is no mesh Go module's. func PackagesKey(module string) (string, error) { if _, _, ok := trunk.PackageRepository(module); !ok { return "", fmt.Errorf("view: %q is no mesh Go module's path", module) } return meshcatalog.PackagesByModuleKey(keys.EscapeName(module)), nil }