summaryrefslogtreecommitdiff
path: root/internal/state.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-01 15:00:59 +0300
committerPaul Buetow <paul@buetow.org>2025-06-01 15:00:59 +0300
commit9fe227b79ea15ffcde8bf175ff879f991d183eab (patch)
treeb033237472a35e60074591e8788ee99c7c5630cc /internal/state.go
parent075ddd7ecec4ab3f0648015857e32c3bb5240743 (diff)
more on federation
Diffstat (limited to 'internal/state.go')
-rw-r--r--internal/state.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/state.go b/internal/state.go
index cda360f..9580db6 100644
--- a/internal/state.go
+++ b/internal/state.go
@@ -70,6 +70,7 @@ func newState(conf config) (state, error) {
return s, nil
}
+
func (s state) update(result checkResult) {
prevStatus := nagiosUnknown
prevState, ok := s.checks[result.name]
@@ -93,6 +94,14 @@ func (s state) merge(other state) error {
return nil
}
+func (s state) mergeFromBytes(bytes []byte) error {
+ var other state
+ if err := json.Unmarshal(bytes, &other.checks); err != nil {
+ return err
+ }
+ return s.merge(other)
+}
+
func (s state) persist() error {
stateDir := filepath.Dir(s.stateFile)
if _, err := os.Stat(stateDir); os.IsNotExist(err) {