forked from statping/statping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
120 lines (120 loc) · 3.76 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Package notifier contains the main functionality for the Statping Notification system
//
// Example Notifier
//
// Below is an example of a Notifier with multiple Form values to custom your inputs. Place your notifier go file
// into the /notifiers/ directory and follow the example below.
//
// type ExampleNotifier struct {
// *Notification
// }
//
// var example = &ExampleNotifier{&Notification{
// Method: "example",
// Title: "Example Notifier",
// Description: "This is an example of a notifier for Statping!",
// Author: "Hunter Long",
// AuthorUrl: "https://github.com/hunterlong",
// Delay: time.Duration(3 * time.Second),
// Limits: 7,
// Form: []NotificationForm{{
// Type: "text",
// Title: "Host",
// Placeholder: "Insert your Host here.",
// DbField: "host",
// SmallText: "this is where you would put the host",
// }, {
// Type: "text",
// Title: "Username",
// Placeholder: "Insert your Username here.",
// DbField: "username",
// }, {
// Type: "password",
// Title: "Password",
// Placeholder: "Insert your Password here.",
// DbField: "password",
// }, {
// Type: "number",
// Title: "Port",
// Placeholder: "Insert your Port here.",
// DbField: "port",
// }, {
// Type: "text",
// Title: "API Key",
// Placeholder: "Insert your API Key here",
// DbField: "api_key",
// }, {
// Type: "text",
// Title: "API Secret",
// Placeholder: "Insert your API Secret here",
// DbField: "api_secret",
// }, {
// Type: "text",
// Title: "Var 1",
// Placeholder: "Insert your Var1 here",
// DbField: "var1",
// }, {
// Type: "text",
// Title: "Var2",
// Placeholder: "Var2 goes here",
// DbField: "var2",
// }},
// }}
//
// Load the Notifier
//
// Include the init() function with AddNotifier and your notification struct. This is ran on start of Statping
// and will automatically create a new row in the database so the end user can save their own values.
//
// func init() {
// AddNotifier(example)
// }
//
// Required Methods for Notifier Interface
//
// Below are the required methods to have your notifier implement the Notifier interface. The Send method
// will be where you would include the logic for your notification.
//
// // REQUIRED
// func (n *ExampleNotifier) Send(msg interface{}) error {
// message := msg.(string)
// fmt.Printf("i received this string: %v\n", message)
// return nil
// }
//
// // REQUIRED
// func (n *ExampleNotifier) Select() *Notification {
// return n.Notification
// }
//
// // REQUIRED
// func (n *ExampleNotifier) OnSave() error {
// msg := fmt.Sprintf("received on save trigger")
// n.AddQueue(msg)
// return errors.New("onsave triggered")
// }
//
// Basic Events for Notifier
//
// You must include OnSuccess and OnFailure methods for your notifier. Anytime a service is online or offline
// these methods will be ran with the service corresponding to it.
//
// // REQUIRED - BASIC EVENT
// func (n *ExampleNotifier) OnSuccess(s *types.Service) {
// msg := fmt.Sprintf("received a count trigger for service: %v\n", s.Name)
// n.AddQueue(msg)
// }
//
// // REQUIRED - BASIC EVENT
// func (n *ExampleNotifier) OnFailure(s *types.Service, f *types.Failure) {
// msg := fmt.Sprintf("received a failure trigger for service: %v\n", s.Name)
// n.AddQueue(msg)
// }
//
// Additional Events
//
// You can implement your notifier to different types of events that are triggered. Checkout the wiki to
// see more details and examples of how to build your own notifier.
//
// More info on: https://github.com/hunterlong/statping/wiki/Notifiers
package notifier