summaryrefslogtreecommitdiff
path: root/internal/state.go
diff options
context:
space:
mode:
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) {