2021-01-25 01:14:21 +02:00
|
|
|
package notify
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
2021-01-25 06:05:28 +02:00
|
|
|
const defaultDisabled = false // Notifier is enabled by default
|
2021-01-25 01:14:21 +02:00
|
|
|
|
2021-01-25 06:05:28 +02:00
|
|
|
// Notify is the central struct for managing notification services and sending messages to them.
|
|
|
|
type Notify struct {
|
|
|
|
Disabled bool
|
|
|
|
notifiers []Notifier
|
|
|
|
}
|
2021-01-25 01:14:21 +02:00
|
|
|
|
2021-01-25 06:05:28 +02:00
|
|
|
// ErrSendNotification signals that the notifier failed to send a notification.
|
2021-01-29 20:53:31 +02:00
|
|
|
var ErrSendNotification = errors.New("send notification")
|
2021-01-25 01:14:21 +02:00
|
|
|
|
2021-01-31 14:14:48 +02:00
|
|
|
// New returns a new instance of Notify. Defaulting to being not disabled
|
2021-01-25 06:05:28 +02:00
|
|
|
func New() *Notify {
|
|
|
|
notifier := &Notify{
|
2021-01-30 22:39:07 +02:00
|
|
|
Disabled: defaultDisabled,
|
|
|
|
notifiers: []Notifier{},
|
2021-01-25 01:14:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return notifier
|
|
|
|
}
|