engine: graph: Add a function for printing Send/Recv logs

This commit is contained in:
James Shubin
2024-01-20 03:16:11 -05:00
parent e5a189b8c6
commit 091bf3a64c
2 changed files with 19 additions and 0 deletions

View File

@@ -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
}