blob: 79d22c7285cbd361aa2572b5ffba56515541c213 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package history
import (
"github.com/go-redis/redis/v8"
"github.com/icinga/icingadb/pkg/icingadb/v1/history"
"github.com/icinga/icingadb/pkg/structify"
"github.com/icinga/icingadb/pkg/types"
"reflect"
)
var slaStateStructify = structify.MakeMapStructifier(reflect.TypeOf((*history.SlaHistoryState)(nil)).Elem(), "json")
func stateHistoryToSlaEntity(entry redis.XMessage) ([]history.UpserterEntity, error) {
slaStateInterface, err := slaStateStructify(entry.Values)
if err != nil {
return nil, err
}
slaState := slaStateInterface.(*history.SlaHistoryState)
if slaState.StateType != types.StateHard {
// only hard state changes are relevant for SLA history, discard all others
return nil, nil
}
return []history.UpserterEntity{slaState}, nil
}
|