2021-12-21 20:51:12 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
)
|
|
|
|
|
|
|
|
func filterChanges(in <-chan RaidState) <-chan RaidState {
|
|
|
|
out := make(chan RaidState, 4)
|
|
|
|
|
|
|
|
go func(in <-chan RaidState, out chan<- RaidState) {
|
|
|
|
defer close(out)
|
|
|
|
|
|
|
|
currentStates := map[string]RaidState{}
|
|
|
|
|
|
|
|
for state := range in {
|
2023-07-19 17:35:51 +02:00
|
|
|
oldState, ok := currentStates[state.Name]
|
|
|
|
if !ok || !reflect.DeepEqual(oldState.DevicesUp, state.DevicesUp) {
|
2021-12-21 20:51:12 +01:00
|
|
|
currentStates[state.Name] = state
|
|
|
|
out <- state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}(in, out)
|
|
|
|
|
|
|
|
return out
|
|
|
|
}
|