mirror of
https://github.com/nikoksr/notify.git
synced 2024-11-30 08:46:43 +02:00
29 lines
728 B
Go
29 lines
728 B
Go
package notify
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
const defaultDisabled = false // Notifier is enabled by default
|
|
|
|
// Notify is the central struct for managing notification services and sending messages to them.
|
|
type Notify struct {
|
|
Disabled bool
|
|
notifiers []Notifier
|
|
}
|
|
|
|
// ErrSendNotification signals that the notifier failed to send a notification.
|
|
var ErrSendNotification = errors.New("send notification")
|
|
|
|
// New returns a new instance of Notify. Defaulting to being not disabled.
|
|
func New() *Notify {
|
|
return &Notify{Disabled: defaultDisabled, notifiers: []Notifier{}}
|
|
}
|
|
|
|
var std = New()
|
|
|
|
// Default returns the standard Notify instance used by the package-level send function.
|
|
func Default() *Notify {
|
|
return std
|
|
}
|