interfaces.go 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package alerting
  2. import "time"
  3. type EvalHandler interface {
  4. Eval(evalContext *EvalContext)
  5. }
  6. type Scheduler interface {
  7. Tick(time time.Time, execQueue chan *Job)
  8. Update(rules []*Rule)
  9. }
  10. type Notifier interface {
  11. Notify(evalContext *EvalContext) error
  12. GetType() string
  13. NeedsImage() bool
  14. // ShouldNotify checks this evaluation should send an alert notification
  15. ShouldNotify(evalContext *EvalContext) bool
  16. GetNotifierId() int64
  17. GetIsDefault() bool
  18. GetSendReminder() bool
  19. GetFrequency() time.Duration
  20. }
  21. type NotifierSlice []Notifier
  22. func (notifiers NotifierSlice) ShouldUploadImage() bool {
  23. for _, notifier := range notifiers {
  24. if notifier.NeedsImage() {
  25. return true
  26. }
  27. }
  28. return false
  29. }
  30. type ConditionResult struct {
  31. Firing bool
  32. NoDataFound bool
  33. Operator string
  34. EvalMatches []*EvalMatch
  35. }
  36. type Condition interface {
  37. Eval(result *EvalContext) (*ConditionResult, error)
  38. }