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