docker health introduced

This commit is contained in:
Tordarus 2021-12-22 22:17:51 +01:00
parent 0d20b75fb6
commit 919aa659cb
4 changed files with 14 additions and 0 deletions

View File

@ -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)

1
go.mod
View File

@ -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
)

2
go.sum
View File

@ -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=

View File

@ -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
}