From 919aa659cb5f62b91c4da0e286acb9157df45890 Mon Sep 17 00:00:00 2001 From: Tordarus Date: Wed, 22 Dec 2021 22:17:51 +0100 Subject: [PATCH] docker health introduced --- filter_changed_states.go | 8 ++++++++ go.mod | 1 + go.sum | 2 ++ main.go | 3 +++ 4 files changed, 14 insertions(+) diff --git a/filter_changed_states.go b/filter_changed_states.go index edf4851..aca8b7f 100644 --- a/filter_changed_states.go +++ b/filter_changed_states.go @@ -2,6 +2,8 @@ package main import ( "reflect" + + "git.tordarus.net/Tordarus/dockerhealth" ) func filterChanges(in <-chan RaidState) <-chan RaidState { @@ -12,11 +14,17 @@ func filterChanges(in <-chan RaidState) <-chan RaidState { currentStates := map[string]RaidState{} + first := true + for state := range in { if oldState, ok := currentStates[state.Name]; !ok || !reflect.DeepEqual(oldState.DevicesUp, state.DevicesUp) { + dockerhealth.Healthy = first currentStates[state.Name] = state out <- state + } else { + dockerhealth.Healthy = true } + first = false } }(in, out) diff --git a/go.mod b/go.mod index 04b962a..bdf6f54 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,6 @@ go 1.17 require ( git.tordarus.net/Tordarus/adverr v0.2.0 + git.tordarus.net/Tordarus/dockerhealth v0.0.1 github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 ) diff --git a/go.sum b/go.sum index 49f673c..83a6e6b 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ git.tordarus.net/Tordarus/adverr v0.2.0 h1:kLYjR2/Vb2GHiSAMvAv+WPNaHR9BRphKanf8H/pCZdA= git.tordarus.net/Tordarus/adverr v0.2.0/go.mod h1:XRf0+7nhOkIEr0gi9DUG4RvV2KaOFB0fYPDaR1KLenw= +git.tordarus.net/Tordarus/dockerhealth v0.0.1 h1:rxkwmCW5PDe9gbnXap7d3n5rK1Qyr6xpmJPZFom/ZXc= +git.tordarus.net/Tordarus/dockerhealth v0.0.1/go.mod h1:U0IPsBJHAjqWgNyehWwGfYqTwPJgqBNhzk/eBpaZsnE= github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc= github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8= diff --git a/main.go b/main.go index f14f4c7..6b37080 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "time" "git.tordarus.net/Tordarus/adverr" + "git.tordarus.net/Tordarus/dockerhealth" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" ) @@ -52,4 +53,6 @@ func main() { adverr.Println(err) } } + + dockerhealth.Healthy = false }