diff --git a/cmd/doc.go b/cmd/doc.go index 9ec0ac66..c1213da0 100644 --- a/cmd/doc.go +++ b/cmd/doc.go @@ -8,5 +8,5 @@ // Remember that you'll need to compile the static assets using Rice: // // cd source && rice embed-go // -// by Hunter Long +// More info on: https://github.com/hunterlong/statup package main diff --git a/core/doc.go b/core/doc.go index 756f715a..66d494c5 100644 --- a/core/doc.go +++ b/core/doc.go @@ -2,5 +2,5 @@ // Services, Hits, Failures, Users, service checking mechanisms, databases, and notifiers // in the notifier package // -// by Hunter Long +// More info on: https://github.com/hunterlong/statup package core diff --git a/core/notifier/doc.go b/core/notifier/doc.go index a52f008d..37414aad 100644 --- a/core/notifier/doc.go +++ b/core/notifier/doc.go @@ -1,4 +1,4 @@ // Package Notifier contains the main functionality for the Statup Notification system // -// by Hunter Long +// More info on: https://github.com/hunterlong/statup/wiki/Notifiers package notifier diff --git a/core/notifier/example_test.go b/core/notifier/example_test.go index dc00fbfe..92719e05 100644 --- a/core/notifier/example_test.go +++ b/core/notifier/example_test.go @@ -22,11 +22,11 @@ import ( "time" ) -type Example struct { +type ExampleNotifier struct { *Notification } -var example = &Example{&Notification{ +var example = &ExampleNotifier{&Notification{ Method: METHOD, Host: "http://exmaplehost.com", Title: "Example", @@ -85,98 +85,142 @@ func init() { } // REQUIRED -func (n *Example) Send(msg interface{}) error { +func (n *ExampleNotifier) Send(msg interface{}) error { message := msg.(string) fmt.Printf("i received this string: %v\n", message) return nil } // REQUIRED -func (n *Example) Select() *Notification { +func (n *ExampleNotifier) Select() *Notification { return n.Notification } // REQUIRED -func (n *Example) OnSave() error { +func (n *ExampleNotifier) OnSave() error { msg := fmt.Sprintf("received on save trigger") n.AddQueue(msg) return errors.New("onsave triggered") } // REQUIRED - BASIC EVENT -func (n *Example) OnSuccess(s *types.Service) { +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 *Example) OnFailure(s *types.Service, f *types.Failure) { +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) } // OPTIONAL Test function before user saves -func (n *Example) OnTest() error { +func (n *ExampleNotifier) OnTest() error { fmt.Printf("received a test trigger with form data: %v\n", n.Host) return nil } // OPTIONAL -func (n *Example) OnNewService(s *types.Service) { +func (n *ExampleNotifier) OnNewService(s *types.Service) { msg := fmt.Sprintf("received a new service trigger for service: %v\n", s.Name) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnUpdatedService(s *types.Service) { +func (n *ExampleNotifier) OnUpdatedService(s *types.Service) { msg := fmt.Sprintf("received a update service trigger for service: %v\n", s.Name) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnDeletedService(s *types.Service) { +func (n *ExampleNotifier) OnDeletedService(s *types.Service) { msg := fmt.Sprintf("received a delete service trigger for service: %v\n", s.Name) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnNewUser(s *types.User) { +func (n *ExampleNotifier) OnNewUser(s *types.User) { msg := fmt.Sprintf("received a new user trigger for user: %v\n", s.Username) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnUpdatedUser(s *types.User) { +func (n *ExampleNotifier) OnUpdatedUser(s *types.User) { msg := fmt.Sprintf("received a updated user trigger for user: %v\n", s.Username) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnDeletedUser(s *types.User) { +func (n *ExampleNotifier) OnDeletedUser(s *types.User) { msg := fmt.Sprintf("received a deleted user trigger for user: %v\n", s.Username) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnUpdatedCore(s *types.Core) { +func (n *ExampleNotifier) OnUpdatedCore(s *types.Core) { msg := fmt.Sprintf("received a updated core trigger for core: %v\n", s.Name) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnStart(s *types.Core) { +func (n *ExampleNotifier) OnStart(s *types.Core) { msg := fmt.Sprintf("received a trigger on Statup boot: %v\n", s.Name) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnNewNotifier(s *Notification) { +func (n *ExampleNotifier) OnNewNotifier(s *Notification) { msg := fmt.Sprintf("received a new notifier trigger for notifier: %v\n", s.Method) n.AddQueue(msg) } // OPTIONAL -func (n *Example) OnUpdatedNotifier(s *Notification) { +func (n *ExampleNotifier) OnUpdatedNotifier(s *Notification) { msg := fmt.Sprintf("received a update notifier trigger for notifier: %v\n", s.Method) n.AddQueue(msg) } + +// Create a new notifier that includes a form for the end user to insert their own values +func Example() { + // Create a new variable for your Notifier + example = &ExampleNotifier{&Notification{ + Method: "Example", + Title: "Example Notifier", + Description: "Example Notifier can hold many different types of fields for a customized look.", + Author: "Hunter Long", + AuthorUrl: "https://github.com/hunterlong", + Delay: time.Duration(1500 * time.Millisecond), + Limits: 7, + Form: []NotificationForm{{ + Type: "text", + Title: "Host", + Placeholder: "Insert your Host here.", + DbField: "host", + SmallText: "you can also use SmallText to insert some helpful hints under this input", + }}, + }} + + // AddNotifier accepts a notifier to load into the Statup Notification system + AddNotifier(example) +} + +// Add any type of interface to the AddQueue function when a service is successful +func Example_onSuccess() { + msg := fmt.Sprintf("this is a successful message as a string passing into AddQueue function") + example.AddQueue(msg) +} + +// Add any type of interface to the AddQueue function when a service is successful +func Example_onFailure() { + msg := fmt.Sprintf("this is a failing message as a string passing into AddQueue function") + example.AddQueue(msg) +} + +// The Send method will run the main functionality of your notifier +func Example_send() { + // example.Send(msg interface{}) + for i := 0; i <= 10; i++ { + fmt.Printf("do something awesome rather than a loop %v\n", i) + } +} diff --git a/handlers/doc.go b/handlers/doc.go index 52de107d..aa86c232 100644 --- a/handlers/doc.go +++ b/handlers/doc.go @@ -1,5 +1,5 @@ // Package handlers holds all the HTTP requests and routes. All HTTP related // functions are in this package. // -// by Hunter Long +// More info on: https://github.com/hunterlong/statup package handlers diff --git a/notifiers/doc.go b/notifiers/doc.go index eae5662a..d6bb4e2b 100644 --- a/notifiers/doc.go +++ b/notifiers/doc.go @@ -5,5 +5,5 @@ // To see a full example of a notifier with all events, visit Statup's // notifier example code: https://github.com/hunterlong/statup/wiki/Notifier-Example // -// by Hunter Long +// More info on: https://github.com/hunterlong/statup package notifiers diff --git a/dev/compose/README.md b/servers/README.md similarity index 100% rename from dev/compose/README.md rename to servers/README.md diff --git a/dev/compose/docker-compose-single.yml b/servers/docker-compose-single.yml similarity index 100% rename from dev/compose/docker-compose-single.yml rename to servers/docker-compose-single.yml diff --git a/dev/compose/docker-compose-ssl.yml b/servers/docker-compose-ssl.yml similarity index 100% rename from dev/compose/docker-compose-ssl.yml rename to servers/docker-compose-ssl.yml diff --git a/dev/compose/docker-compose-test.yml b/servers/docker-compose-test.yml similarity index 100% rename from dev/compose/docker-compose-test.yml rename to servers/docker-compose-test.yml diff --git a/dev/compose/docker-compose.yml b/servers/docker-compose.yml similarity index 100% rename from dev/compose/docker-compose.yml rename to servers/docker-compose.yml diff --git a/dev/compose/ec2-ssl.sh b/servers/ec2-ssl.sh similarity index 100% rename from dev/compose/ec2-ssl.sh rename to servers/ec2-ssl.sh diff --git a/dev/compose/init.service b/servers/init.service similarity index 100% rename from dev/compose/init.service rename to servers/init.service diff --git a/dev/compose/init.sh b/servers/init.sh similarity index 100% rename from dev/compose/init.sh rename to servers/init.sh diff --git a/source/doc.go b/source/doc.go index b48bf193..6ae80632 100644 --- a/source/doc.go +++ b/source/doc.go @@ -4,5 +4,5 @@ // // To compile all the assets run `rice embed-go` in the source directory. // -// by Hunter Long +// More info on: https://github.com/hunterlong/statup package source diff --git a/types/doc.go b/types/doc.go index 99b7faf2..cbb860c2 100644 --- a/types/doc.go +++ b/types/doc.go @@ -1,4 +1,4 @@ // Package types contains all of the structs for objects in Statup including services, hits, failures, Core, and others. // -// by Hunter Long +// More info on: https://github.com/hunterlong/statup package types diff --git a/utils/doc.go b/utils/doc.go index 6cf016a6..b918dd87 100644 --- a/utils/doc.go +++ b/utils/doc.go @@ -6,5 +6,5 @@ // You can overwrite the utils.Directory global variable by including // STATUP_DIR environment variable to be an absolute path. // -// by Hunter Long +// More info on: https://github.com/hunterlong/statup package utils