From 887a9762630d59c0e62f4ee24a3c1891aa4f64f8 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Mon, 31 Jul 2023 16:37:32 -0600 Subject: [PATCH] Write node to DB every signal --- node.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/node.go b/node.go index ff3b518..0583eb5 100644 --- a/node.go +++ b/node.go @@ -252,6 +252,13 @@ func nodeLoop(ctx *Context, node *Node) error { } node.Process(ctx, source, signal) + // assume that processing a signal means that this nodes state changed + // TODO: remove a lot of database writes by only writing when things change, + // so need to have Process return whether or not state changed + err := WriteNode(ctx, node) + if err != nil { + panic(err) + } } stopped := node.Active.CompareAndSwap(true, false)