Start working on notifications when service is back to healthy (#9)

This commit is contained in:
TwinProduction
2020-09-04 18:23:56 -04:00
parent db7c516819
commit 51ea912cf9
5 changed files with 93 additions and 68 deletions

View File

@ -21,6 +21,10 @@ type TwilioAlertProvider struct {
To string `yaml:"to"`
}
func (provider *TwilioAlertProvider) IsValid() bool {
return len(provider.Token) > 0 && len(provider.SID) > 0 && len(provider.From) > 0 && len(provider.To) > 0
}
type CustomAlertProvider struct {
Url string `yaml:"url"`
Method string `yaml:"method,omitempty"`
@ -28,6 +32,10 @@ type CustomAlertProvider struct {
Headers map[string]string `yaml:"headers,omitempty"`
}
func (provider *CustomAlertProvider) IsValid() bool {
return len(provider.Url) > 0
}
func (provider *CustomAlertProvider) buildRequest(serviceName, alertDescription string) *http.Request {
body := provider.Body
url := provider.Url