interfaces.go 948 B

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