statping/types/services/notifier.go

32 lines
817 B
Go
Raw Normal View History

2020-03-14 03:13:20 +00:00
package services
import (
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications"
)
var (
allNotifiers []ServiceNotifier
)
func AllNotifiers() []ServiceNotifier {
return allNotifiers
}
2020-03-25 18:46:50 +00:00
func FindNotifier(method string) *notifications.Notification {
for _, n := range allNotifiers {
notif := n.Select()
if notif.Method == method {
return notif
}
}
return nil
}
2020-03-14 03:13:20 +00:00
type ServiceNotifier interface {
OnSuccess(*Service) error // OnSuccess is triggered when a service is successful
OnFailure(*Service, *failures.Failure) error // OnFailure is triggered when a service is failing
OnTest() error // OnTest is triggered for testing
Select() *notifications.Notification // OnTest is triggered for testing
}