Files
mesh-catalog/modules/mesh-provisioner/cmd/mesh-provisioner/readers.go
T

32 lines
973 B
Go

package main
import (
"encoding/json"
"fmt"
meshwants "git.novox.be/novox/mesh-contracts/placement/go/seats/meshwants"
)
// The holders whose states this module reads, one constant each (a reader names its holder once; ADR 0634 §4).
const (
assignerModule = "mesh-delivery-assigner"
indexerModule = "mesh-delivery-indexer"
)
// parseWantKey reads a want's key, `want.<node>.<module>`; the want of a node's own and a held fingerprint's key are
// not one.
func parseWantKey(key string) (node, module string, err error) {
node, module, ok := meshwants.ParseWantsByWantNodeModuleKey(key)
if !ok {
return "", "", fmt.Errorf("%q is not the key of a module's want on a node", key)
}
return node, module, nil
}
// decodeWant reads a want of a module on a node, as the wants seat types it.
func decodeWant(value []byte) (meshwants.WantsByWantNodeModuleValue, error) {
var w meshwants.WantsByWantNodeModuleValue
err := json.Unmarshal(value, &w)
return w, err
}