1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-01-07 23:01:59 +02:00
notify/notify.go

29 lines
728 B
Go
Raw Normal View History

2021-01-25 01:14:21 +02:00
package notify
import (
"github.com/pkg/errors"
)
const defaultDisabled = false // Notifier is enabled by default
2021-01-25 01:14:21 +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
// ErrSendNotification signals that the notifier failed to send a notification.
var ErrSendNotification = errors.New("send notification")
2021-01-25 01:14:21 +02:00
// New returns a new instance of Notify. Defaulting to being not disabled.
func New() *Notify {
return &Notify{Disabled: defaultDisabled, notifiers: []Notifier{}}
}
var std = New()
2021-01-25 01:14:21 +02:00
// Default returns the standard Notify instance used by the package-level send function.
func Default() *Notify {
return std
2021-01-25 01:14:21 +02:00
}