The state, events and types of the seat mesh-module-assigner say assignments; the legacy node key form is gone from the reads; the dead seat-verb list of the retired name is deleted. The placement guard and the placed-file sense stay. Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
63 lines
2.1 KiB
Go
63 lines
2.1 KiB
Go
// Package bucketstest writes the values of the states the engine only reads (a want, a assignment candidate) as their
|
|
// holders do, for the tests that stand in for the holders.
|
|
package bucketstest
|
|
|
|
import (
|
|
"encoding/json"
|
|
"git.novox.be/novox/mesh-delivery/contracts/go/clients/meshdeliveryclient"
|
|
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
|
|
|
"git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
|
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
|
|
)
|
|
|
|
// Version is the value version the holders write.
|
|
const Version = 1
|
|
|
|
// Want is a module's want as the wants seat's holder writes it.
|
|
func Want(w meshwants.WantsByWantNodeModuleValue) ([]byte, error) {
|
|
w.V = Version
|
|
return json.Marshal(w)
|
|
}
|
|
|
|
// NodeWant is a node's own want as the wants seat's holder writes it.
|
|
func NodeWant(w meshwants.WantsByWantNodeNodeValue) ([]byte, error) {
|
|
w.V = Version
|
|
return json.Marshal(w)
|
|
}
|
|
|
|
// Candidate is a node's candidate of a proposal as the assignment seat's holder writes it.
|
|
func Candidate(c meshmoduleassigner.CandidatesByProposalNodeValue) ([]byte, error) {
|
|
c.V = Version
|
|
if c.Assignments != nil {
|
|
p := *c.Assignments
|
|
p.V = Version
|
|
c.Assignments = &p
|
|
}
|
|
return json.Marshal(c)
|
|
}
|
|
|
|
// GroupCandidate is a group's candidate as the catalogue seat's holder writes it.
|
|
func GroupCandidate(c meshcatalog.CandidatesByGroupValue) ([]byte, error) {
|
|
c.V = Version
|
|
return json.Marshal(c)
|
|
}
|
|
|
|
// Pull is one pull request of a candidate, from its head.
|
|
func Pull(head meshdeliveryclient.Head, modules []string, fps map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue) meshcatalog.CandidatesByGroupValuePullsItem {
|
|
return meshcatalog.CandidatesByGroupValuePullsItem{Repository: head.Repository, Number: int64(head.Number), Head: head.Head, Modules: modules, Fps: fps}
|
|
}
|
|
|
|
// Raw is each value as JSON, as a composer case carries verdicts and assignments.
|
|
func Raw[V any](in map[string]V) map[string]json.RawMessage {
|
|
out := map[string]json.RawMessage{}
|
|
for k, v := range in {
|
|
raw, err := json.Marshal(v)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
out[k] = raw
|
|
}
|
|
return out
|
|
}
|