2016-06-06 04:56:58 -05:00
|
|
|
package alerting
|
|
|
|
|
2016-10-03 02:38:03 -05:00
|
|
|
import "time"
|
2016-06-06 04:56:58 -05:00
|
|
|
|
2016-07-27 09:29:28 -05:00
|
|
|
type EvalHandler interface {
|
2016-10-03 02:38:03 -05:00
|
|
|
Eval(evalContext *EvalContext)
|
2016-06-06 04:56:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type Scheduler interface {
|
2016-07-27 09:29:28 -05:00
|
|
|
Tick(time time.Time, execQueue chan *Job)
|
|
|
|
Update(rules []*Rule)
|
2016-06-06 04:56:58 -05:00
|
|
|
}
|
2016-06-15 02:19:22 -05:00
|
|
|
|
|
|
|
type Notifier interface {
|
2016-10-03 02:38:03 -05:00
|
|
|
Notify(evalContext *EvalContext) error
|
2016-07-25 06:52:17 -05:00
|
|
|
GetType() string
|
2016-07-29 07:55:02 -05:00
|
|
|
NeedsImage() bool
|
2017-11-15 10:53:02 -06:00
|
|
|
ShouldNotify(evalContext *EvalContext) bool
|
2016-10-11 03:13:19 -05:00
|
|
|
|
|
|
|
GetNotifierId() int64
|
|
|
|
GetIsDefault() bool
|
2016-06-15 02:19:22 -05:00
|
|
|
}
|
2016-07-19 10:45:37 -05:00
|
|
|
|
2017-02-13 05:43:12 -06:00
|
|
|
type NotifierSlice []Notifier
|
|
|
|
|
|
|
|
func (notifiers NotifierSlice) ShouldUploadImage() bool {
|
|
|
|
for _, notifier := range notifiers {
|
|
|
|
if notifier.NeedsImage() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-11-03 09:26:17 -05:00
|
|
|
type ConditionResult struct {
|
|
|
|
Firing bool
|
|
|
|
NoDataFound bool
|
2016-11-15 08:35:25 -06:00
|
|
|
Operator string
|
2016-11-03 09:26:17 -05:00
|
|
|
EvalMatches []*EvalMatch
|
|
|
|
}
|
|
|
|
|
2016-07-27 09:29:28 -05:00
|
|
|
type Condition interface {
|
2016-11-03 09:26:17 -05:00
|
|
|
Eval(result *EvalContext) (*ConditionResult, error)
|
2016-07-19 10:45:37 -05:00
|
|
|
}
|