summaryrefslogtreecommitdiffstats
path: root/pkg/icingadb/v1/history/state.go
blob: dec13b042cffb57ab8c88fd7cc852ef09bb94f4e (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package history

import (
	"github.com/icinga/icingadb/pkg/contracts"
	"github.com/icinga/icingadb/pkg/types"
)

type StateHistory struct {
	HistoryTableEntity `json:",inline"`
	HistoryTableMeta   `json:",inline"`
	EventTime          types.UnixMilli `json:"event_time"`
	StateType          types.StateType `json:"state_type"`
	SoftState          uint8           `json:"soft_state"`
	HardState          uint8           `json:"hard_state"`
	PreviousSoftState  uint8           `json:"previous_soft_state"`
	PreviousHardState  uint8           `json:"previous_hard_state"`
	CheckAttempt       uint8           `json:"check_attempt"`
	Output             types.String    `json:"output"`
	LongOutput         types.String    `json:"long_output"`
	MaxCheckAttempts   uint32          `json:"max_check_attempts"`
	CheckSource        types.String    `json:"check_source"`
	SchedulingSource   types.String    `json:"scheduling_source"`
}

type HistoryState struct {
	HistoryMeta    `json:",inline"`
	StateHistoryId types.Binary    `json:"id"`
	EventTime      types.UnixMilli `json:"event_time"`
}

// TableName implements the contracts.TableNamer interface.
func (*HistoryState) TableName() string {
	return "history"
}

type SlaHistoryState struct {
	HistoryTableEntity `json:",inline"`
	HistoryTableMeta   `json:",inline"`
	EventTime          types.UnixMilli `json:"event_time"`
	StateType          types.StateType `json:"state_type" db:"-"`
	HardState          uint8           `json:"hard_state"`
	PreviousHardState  uint8           `json:"previous_hard_state"`
}

// Assert interface compliance.
var (
	_ UpserterEntity       = (*StateHistory)(nil)
	_ contracts.TableNamer = (*HistoryState)(nil)
	_ UpserterEntity       = (*HistoryState)(nil)
	_ UpserterEntity       = (*SlaHistoryState)(nil)
)