refactoring(alerting PR #6354): added new option type for NoData option so AlertStateType does not have to contain invalid state, #6354
This commit is contained in:
+15
-1
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
type AlertStateType string
|
||||
type AlertSeverityType string
|
||||
type NoDataOption string
|
||||
|
||||
const (
|
||||
AlertStateNoData AlertStateType = "no_data"
|
||||
@@ -15,14 +16,27 @@ const (
|
||||
AlertStatePaused AlertStateType = "paused"
|
||||
AlertStateAlerting AlertStateType = "alerting"
|
||||
AlertStateOK AlertStateType = "ok"
|
||||
)
|
||||
|
||||
KeepLastAlertState AlertStateType = "keep_last"
|
||||
const (
|
||||
NoDataSetNoData NoDataOption = "no_data"
|
||||
NoDataSetAlerting NoDataOption = "alerting"
|
||||
NoDataSetOK NoDataOption = "ok"
|
||||
NoDataKeepState NoDataOption = "keep_state"
|
||||
)
|
||||
|
||||
func (s AlertStateType) IsValid() bool {
|
||||
return s == AlertStateOK || s == AlertStateNoData || s == AlertStateExecError || s == AlertStatePaused
|
||||
}
|
||||
|
||||
func (s NoDataOption) IsValid() bool {
|
||||
return s == NoDataSetNoData || s == NoDataSetAlerting || s == NoDataSetOK || s == NoDataKeepState
|
||||
}
|
||||
|
||||
func (s NoDataOption) ToAlertState() AlertStateType {
|
||||
return AlertStateType(s)
|
||||
}
|
||||
|
||||
type Alert struct {
|
||||
Id int64
|
||||
Version int64
|
||||
|
||||
Reference in New Issue
Block a user