More 'improvements' based on goreportcard.com

This commit is contained in:
Matej Kramny
2015-03-20 20:52:57 +01:00
parent 3d0b0c88e1
commit cdf51d89f6
5 changed files with 16 additions and 16 deletions

View File

@@ -4,7 +4,7 @@ import (
"time"
)
// Cachet component model
// Component Cachet model
type Component struct {
ID int `json:"id"`
Name string `json:"name"`
@@ -12,7 +12,7 @@ type Component struct {
Status int `json:"status"`
Link *string `json:"link"`
Order *int `json:"order"`
GroupId *int `json:"group_id"`
GroupID *int `json:"group_id"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`

View File

@@ -13,7 +13,7 @@ import (
// Static config
var Config CachetConfig
// Monitoring tool configuration
// CachetConfig is the monitoring tool configuration
type CachetConfig struct {
APIUrl string `json:"api_url"`
APIToken string `json:"api_token"`

View File

@@ -6,7 +6,7 @@ import (
"encoding/json"
)
// Cachet Incident data model
// Incident Cachet data model
type Incident struct {
ID int `json:"id"`
Name string `json:"name"`
@@ -14,22 +14,22 @@ type Incident struct {
Status int `json:"status"`// 4?
HumanStatus string `json:"human_status"`
Component *Component `json:"component"`
ComponentId *int `json:"component_id"`
ComponentID *int `json:"component_id"`
CreatedAt int `json:"created_at"`
UpdatedAt int `json:"updated_at"`
}
// Response when creating/updating an incident
// IncidentData is a response when creating/updating an incident
type IncidentData struct {
Incident Incident `json:"data"`
}
// from API /incidents
// IncidentList - from API /incidents
type IncidentList struct {
Incidents []Incident `json:"data"`
}
// Get list of incidents
// GetIncidents - Get list of incidents
func GetIncidents() []Incident {
_, body, err := makeRequest("GET", "/incidents", nil)
if err != nil {
@@ -45,7 +45,7 @@ func GetIncidents() []Incident {
return data.Incidents
}
// Create or Update incident
// Send - Create or Update incident
func (incident *Incident) Send() {
jsonBytes, err := json.Marshal(incident)
if err != nil {
@@ -83,7 +83,7 @@ func (incident *Incident) Send() {
}
// Get the same incident.
// Updates incident.ID
// GetSimilarIncidentId Updates incident.ID
func (incident *Incident) GetSimilarIncidentId() {
incidents := GetIncidents()
@@ -96,25 +96,25 @@ func (incident *Incident) GetSimilarIncidentId() {
}
}
// Set status to Investigating
// SetInvestigating sets status to Investigating
func (incident *Incident) SetInvestigating() {
incident.Status = 1
incident.HumanStatus = "Investigating"
}
// Set status to Identified
// SetIdentified sets status to Identified
func (incident *Incident) SetIdentified() {
incident.Status = 2
incident.HumanStatus = "Identified"
}
// Set status to Watching
// SetWatching sets status to Watching
func (incident *Incident) SetWatching() {
incident.Status = 3
incident.HumanStatus = "Watching"
}
// Set status to Fixed
// SetFixed sets status to Fixed
func (incident *Incident) SetFixed() {
incident.Status = 4
incident.HumanStatus = "Fixed"

View File

@@ -6,7 +6,7 @@ import (
"encoding/json"
)
// Send lag metric point
// SendMetric sends lag metric point
func SendMetric(metricID int, delay int64) {
if metricID <= 0 {
return

View File

@@ -55,7 +55,7 @@ func (monitor *Monitor) doRequest() bool {
return resp.StatusCode == monitor.ExpectedStatusCode
}
// Decides if the monitor is statistically up or down and creates / resolves an incident
// AnalyseData decides if the monitor is statistically up or down and creates / resolves an incident
func (monitor *Monitor) AnalyseData() {
// look at the past few incidents
numDown := 0