Table of contents
Notifiers are functions to notify a user if a service goes offline and when it goes online again. There are several methods to receive notifications (see below).
There are two types of notifiers: configurable and non-configurable.
The keys under the "notifiers" object are the notifiers names. They must be explicitly specified to be activated. Non-configurable notifiers do not require a configuration, so specifying {} as value is sufficient. To provide configuration to configurable notifiers, please consult the notifier-specific documentation (see below).
Notifier list
Adding notifiers
To add a non-configurable notifier, create a go file in server/notify/notifiers with a struct implementing the following interface:
type Notifier interface {
NotifyDown(serviceName string, reportedDownAt time.Time, reason string) error
NotifyUp(serviceName string, reportedDownAt time.Time, wasDownFor time.Duration) error
}
To also make it configurable, also implement this interface:
type ConfigurableNotifier interface {
Notifier
UnmarshalConfig(raw json.RawMessage) error
}
When done, just add an init function, and register the struct there with a name.
func init() {
notify.Register("your-name", YourStruct{})
}
When your notifier ist configurable, than you can configure it in the config.json under the following key:
{
"notifiers": {
"your-name": {} // <-- this object will be provided to the `UnmashalConfig` function
},
...
}
You can take a look at the log notifier for a simple example.