2021-01-25 00:14:21 +01:00
|
|
|
package notify
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
2021-01-25 05:05:28 +01:00
|
|
|
const defaultDisabled = false // Notifier is enabled by default
|
2021-01-25 00:14:21 +01:00
|
|
|
|
2021-01-25 05:05:28 +01: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 00:14:21 +01:00
|
|
|
|
2021-01-25 05:05:28 +01:00
|
|
|
// ErrSendNotification signals that the notifier failed to send a notification.
|
2021-01-29 19:53:31 +01:00
|
|
|
var ErrSendNotification = errors.New("send notification")
|
2021-01-25 00:14:21 +01:00
|
|
|
|
2021-02-10 14:49:25 +01:00
|
|
|
// New returns a new instance of Notify. Defaulting to being not disabled.
|
2021-01-25 05:05:28 +01:00
|
|
|
func New() *Notify {
|
|
|
|
notifier := &Notify{
|
2021-01-30 20:39:07 +00:00
|
|
|
Disabled: defaultDisabled,
|
|
|
|
notifiers: []Notifier{},
|
2021-01-25 00:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return notifier
|
|
|
|
}
|