From 091bf3a64c8b74b254fd1f0f2d467ee76f8d185b Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sat, 20 Jan 2024 03:16:11 -0500 Subject: [PATCH] engine: graph: Add a function for printing Send/Recv logs --- engine/graph/actions.go | 3 +++ engine/graph/sendrecv.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/engine/graph/actions.go b/engine/graph/actions.go index 164b9972..47c35950 100644 --- a/engine/graph/actions.go +++ b/engine/graph/actions.go @@ -124,6 +124,9 @@ func (obj *Engine) Process(ctx context.Context, vertex pgraph.Vertex) error { if updated, err := SendRecv(res); err != nil { return errwrap.Wrapf(err, "could not SendRecv") } else if len(updated) > 0 { + //for _, s := range graph.UpdatedStrings(updated) { + // obj.Logf("SendRecv: %s", s) + //} for r, m := range updated { // map[engine.RecvableRes]map[string]*engine.Send v, ok := r.(pgraph.Vertex) if !ok { diff --git a/engine/graph/sendrecv.go b/engine/graph/sendrecv.go index d2268448..350f659e 100644 --- a/engine/graph/sendrecv.go +++ b/engine/graph/sendrecv.go @@ -243,3 +243,19 @@ func TypeCmp(a, b reflect.Value) error { return nil // identical Type()'s } + +// UpdatedStrings returns a list of strings showing what was updated after a +// Send/Recv run returned the updated datastructure. This is useful for logs. +func UpdatedStrings(updated map[engine.RecvableRes]map[string]*engine.Send) []string { + out := []string{} + for r, m := range updated { // map[engine.RecvableRes]map[string]*engine.Send + for s, send := range m { + if !send.Changed { + continue + } + x := fmt.Sprintf("%v.%s -> %v.%s", send.Res, send.Key, r, s) + out = append(out, x) + } + } + return out +}