packageEntries, manifestBytes, writtenModules, WriteHeard, heldOldSections, keepOldSections, the overlay's written and changed, moduleOfDir with moduleAt, EncodeSeriesPackage, InputDigest, HoldSeats and the barBlock shape's functions are referenced by no file of the repository; with HoldSeats gone the seat list's lock is a plain mutex WithSeats takes. barShows and barOption stay: a judge test reads them. Builds: design 47 H §764; lead answer H-A-48 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
package index
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
)
|
|
|
|
// From R4e the indexer lists a repository's modules from what it holds itself (novox/hq ADR 0501 clause 6, issue 1851):
|
|
// a merged message's manifests name the modules of the merge, and the modules bucket names the modules it wrote before,
|
|
// with their repository and directory. The controller's build records name none of them (ADR 0453 clause 5 keeps only
|
|
// the builder's own input from them until R4g, builds.go).
|
|
|
|
// manifestModule is the module a manifest names itself (its `module`), or "" when it names none or is not JSON. Only the
|
|
// name is read here; the manifest is read whole by the catalogue's parser (inputs.go).
|
|
func manifestModule(raw string) string {
|
|
var m struct {
|
|
Module string `json:"module"`
|
|
}
|
|
if json.Unmarshal([]byte(raw), &m) != nil {
|
|
return ""
|
|
}
|
|
return m.Module
|
|
}
|
|
|
|
// heldModules are the values the modules bucket holds, by key (the module's name). A value that is not a module is left
|
|
// out and said.
|
|
func (ix *Indexer) heldModules(ctx context.Context) (map[string]meshcatalog.ModulesByModuleValue, error) {
|
|
out := map[string]meshcatalog.ModulesByModuleValue{}
|
|
if ix.Modules == nil {
|
|
return out, nil
|
|
}
|
|
keys, err := ix.Modules.Keys(ctx)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("listing the modules: %w", err)
|
|
}
|
|
for _, key := range keys {
|
|
value, _, found, err := ix.Modules.Get(ctx, key)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("modules.%s: %w", key, err)
|
|
}
|
|
if !found {
|
|
continue
|
|
}
|
|
m, err := meshcatalogclient.DecodeModule(value)
|
|
if err != nil {
|
|
ix.logf("modules.%s holds what is not a module, left: %v", key, err)
|
|
continue
|
|
}
|
|
out[key] = m
|
|
}
|
|
return out, nil
|
|
}
|