interfaces.go 834 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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(evalContext *EvalContext) bool
  15. GetNotifierId() int64
  16. GetIsDefault() bool
  17. GetNotifyOnce() bool
  18. GetFrequency() time.Duration
  19. }
  20. type NotifierSlice []Notifier
  21. func (notifiers NotifierSlice) ShouldUploadImage() bool {
  22. for _, notifier := range notifiers {
  23. if notifier.NeedsImage() {
  24. return true
  25. }
  26. }
  27. return false
  28. }
  29. type ConditionResult struct {
  30. Firing bool
  31. NoDataFound bool
  32. Operator string
  33. EvalMatches []*EvalMatch
  34. }
  35. type Condition interface {
  36. Eval(result *EvalContext) (*ConditionResult, error)
  37. }