docker health introduced
This commit is contained in:
parent
0d20b75fb6
commit
919aa659cb
@ -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
1
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
|
||||
)
|
||||
|
2
go.sum
2
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=
|
||||
|
Loading…
Reference in New Issue
Block a user