interfaces.go 768 B

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