Updated Notifiers (markdown)

master
Hunter Long 2020-05-01 05:44:51 -07:00
parent 1dcf6f974c
commit c65a247953
1 changed files with 6 additions and 26 deletions

@ -18,35 +18,15 @@ Statping has the `Notifier` interface which you'll need to include in your notif
```go
// Notifier interface is required to create a new Notifier
type Notifier interface {
OnSave() error // OnSave is triggered when the notifier is saved
Send(interface{}) error // OnSave is triggered when the notifier is saved
Select() *Notification // Select returns the *Notification for a notifier
// OnSuccess is triggered when a service is successful
OnSuccess(*services.Service) error
// OnFailure is triggered when a service is failing
OnFailure(*services.Service, *failures.Failure) error
// OnTest is triggered for testing
OnTest() (string, error)
}
```
### Basic Interface (required)
Include `OnSuccess` and `OnFailure` to receive events when a service is online or offline.
```go
// BasicEvents includes the most minimal events, failing and successful service triggers
type BasicEvents interface {
// OnSuccess is triggered when a service is successful
OnSuccess(*types.Service)
// OnFailure is triggered when a service is failing
OnFailure(*types.Service, *types.Failure)
}
```
### Test Interface
The OnTest method will give the front end user the ability to test your notifier without saving, the OnTest method for your notifier run the functionality to test the user's submitted parameters and respond an error if notifier is not correctly setup.
```go
// Tester interface will include a function to Test users settings before saving
type Tester interface {
OnTest() error
}
```
If your notifier includes this interface, the Test button will appear.
## Notifier Struct
```go
var example = &Example{&notifier.Notification{
Method: "example", // unique method name