From 15c6e02e46a18c6e1705b15b70be2b0fda4ee0e8 Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Sun, 7 Oct 2018 02:27:43 -0700 Subject: [PATCH] docs --- core/notifier/doc.go | 54 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/core/notifier/doc.go b/core/notifier/doc.go index 0302c5ba..23cf3604 100644 --- a/core/notifier/doc.go +++ b/core/notifier/doc.go @@ -2,7 +2,8 @@ // // Example Notifier // -// Below is an example of a Notifier with multiple Form values to custom your inputs. +// 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 @@ -61,11 +62,60 @@ // }}, // }} // -// Loading the Notifier into the Statup Notification system with the following +// Load the Notifier +// +// Include the init() function with AddNotifier and your notification struct. This is ran on start of Statup +// 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/statup/wiki/Notifiers package notifier