Trace a rotation's credential writes and compositions, record the bindings a composition carries, drop SchemaReachOf, and re-pin mesh-sdk to e45bdc0891bb (issue 1945)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
sdkdelivery "git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
)
|
||||
|
||||
// composeTrace, when set, is told what composing a node saw and decided: the Input's credential state before it composes, and for
|
||||
// each module the digest it composed against the digest already written. A test sets it to read why a composition did or did not
|
||||
// move; the controller never does.
|
||||
var composeTrace func(string)
|
||||
|
||||
// traceInput says what the node's composition will read of the pair credentials: those no row holds (would-make) and those held.
|
||||
func traceInput(ctx context.Context, open *stores, node string) {
|
||||
in, err := inputFor(ctx, open)
|
||||
if err != nil {
|
||||
composeTrace(fmt.Sprintf("%s: the Input cannot be read: %v", node, err))
|
||||
return
|
||||
}
|
||||
composeTrace(fmt.Sprintf("%s: before composing, would make %+v; credentials held %+v", node, in.wouldMake, in.Credentials))
|
||||
}
|
||||
|
||||
// traceComposed says, per composition of a node, the digest composed now against the one written.
|
||||
func traceComposed(ctx context.Context, at composedPlace, node string, comps map[string]sdkdelivery.Composed) {
|
||||
keys := make([]string, 0, len(comps))
|
||||
for k := range comps {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, key := range keys {
|
||||
now, err := sdkdelivery.ComposedDigestOf(comps[key])
|
||||
if err != nil {
|
||||
composeTrace(fmt.Sprintf("%s: %s: no digest: %v", node, key, err))
|
||||
continue
|
||||
}
|
||||
written := "none"
|
||||
if e, err := at.digests.Get(ctx, key); err == nil {
|
||||
if v, err := sdkdelivery.DecodeComposedDigest(e.Value()); err == nil {
|
||||
written = v.Digest
|
||||
}
|
||||
}
|
||||
same := "CHANGED"
|
||||
if written == now {
|
||||
same = "same"
|
||||
}
|
||||
composeTrace(fmt.Sprintf("%s: %s: composed %.19s, written %.19s: %s", node, key, now, written, same))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user