Improve code documentation

This commit is contained in:
TwinProduction 2020-10-23 16:12:53 -04:00
parent 4e3856c638
commit 0b1f20d0de
3 changed files with 16 additions and 4 deletions

View File

@ -7,9 +7,17 @@ import (
"github.com/TwinProduction/gatus/alerting/provider/twilio" "github.com/TwinProduction/gatus/alerting/provider/twilio"
) )
// Config is the configuration for alerting providers
type Config struct { type Config struct {
Slack *slack.AlertProvider `yaml:"slack"` // Slack is the configuration for the slack alerting provider
Slack *slack.AlertProvider `yaml:"slack"`
// Pagerduty is the configuration for the pagerduty alerting provider
PagerDuty *pagerduty.AlertProvider `yaml:"pagerduty"` PagerDuty *pagerduty.AlertProvider `yaml:"pagerduty"`
Twilio *twilio.AlertProvider `yaml:"twilio"`
Custom *custom.AlertProvider `yaml:"custom"` // Twilio is the configuration for the twilio alerting provider
Twilio *twilio.AlertProvider `yaml:"twilio"`
// Custom is the configuration for the custom alerting provider
Custom *custom.AlertProvider `yaml:"custom"`
} }

View File

@ -16,7 +16,9 @@ func (provider *AlertProvider) IsValid() bool {
return len(provider.IntegrationKey) == 32 return len(provider.IntegrationKey) == 32
} }
// https://developer.pagerduty.com/docs/events-api-v2/trigger-events/ // ToCustomAlertProvider converts the provider into a custom.AlertProvider
//
// relevant: https://developer.pagerduty.com/docs/events-api-v2/trigger-events/
func (provider *AlertProvider) ToCustomAlertProvider(service *core.Service, alert *core.Alert, result *core.Result, resolved bool) *custom.AlertProvider { func (provider *AlertProvider) ToCustomAlertProvider(service *core.Service, alert *core.Alert, result *core.Result, resolved bool) *custom.AlertProvider {
var message, eventAction, resolveKey string var message, eventAction, resolveKey string
if resolved { if resolved {

View File

@ -15,6 +15,8 @@ var (
rwLock sync.RWMutex rwLock sync.RWMutex
) )
// PublishMetricsForService publishes metrics for the given service and its result.
// These metrics will be exposed at /metrics if the metrics are enabled
func PublishMetricsForService(service *core.Service, result *core.Result) { func PublishMetricsForService(service *core.Service, result *core.Result) {
if config.Get().Metrics { if config.Get().Metrics {
rwLock.Lock() rwLock.Lock()