diff options
Diffstat (limited to 'internal/state.go')
| -rw-r--r-- | internal/state.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/state.go b/internal/state.go index f37a0f6..d37ecf4 100644 --- a/internal/state.go +++ b/internal/state.go @@ -26,7 +26,7 @@ type state struct { checks map[string]checkState } -func readState(conf config) (state, error) { +func newState(conf config) (state, error) { s := state{ stateFile: fmt.Sprintf("%s/state.json", conf.StateDir), checks: make(map[string]checkState), @@ -79,6 +79,17 @@ func (s state) update(result checkResult) { log.Println(result.name, cs) } +// To be used to merge the state of another server running Gogios +func (s state) merge(other state) error { + for name, cs := range other.checks { + if _, ok := s.checks[name]; ok { + return fmt.Errorf("can't merge state due to duplicate check name '%s'", name) + } + s.checks[name] = cs + } + return nil +} + func (s state) persist() error { stateDir := filepath.Dir(s.stateFile) if _, err := os.Stat(stateDir); os.IsNotExist(err) { |
