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:
Torkel Ödegaard
2016-10-22 10:54:50 +02:00
parent ad56f67ad1
commit a2e14f56e4
4 changed files with 52 additions and 41 deletions
+15 -1
View File
@@ -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