1
0
Fork 0
mirror of https://github.com/TwiN/gatus.git synced 2024-12-15 17:51:09 +00:00
twin-gatus/core/result.go

61 lines
1.7 KiB
Go
Raw Normal View History

2019-09-07 00:25:31 +00:00
package core
import (
"time"
)
// Result of the evaluation of a Endpoint
2019-09-07 00:25:31 +00:00
type Result struct {
2020-10-23 20:29:20 +00:00
// HTTPStatus is the HTTP response status code
HTTPStatus int `json:"status"`
// DNSRCode is the response code of a DNS query in a human-readable format
2020-11-30 14:40:57 +00:00
DNSRCode string `json:"-"`
2020-11-17 23:55:31 +00:00
// Hostname extracted from Endpoint.URL
2021-11-04 02:18:23 +00:00
Hostname string `json:"hostname,omitempty"`
// IP resolved from the Endpoint URL
2020-10-23 20:29:20 +00:00
IP string `json:"-"`
// Connected whether a connection to the host was established successfully
Connected bool `json:"-"`
// Duration time that the request took
Duration time.Duration `json:"duration"`
// Errors encountered during the evaluation of the Endpoint's health
2021-11-04 02:18:23 +00:00
Errors []string `json:"errors,omitempty"`
// ConditionResults results of the Endpoint's conditions
ConditionResults []*ConditionResult `json:"conditionResults"`
// Success whether the result signifies a success or not
Success bool `json:"success"`
// Timestamp when the request was sent
Timestamp time.Time `json:"timestamp"`
// CertificateExpiration is the duration before the certificate expires
2020-11-30 14:40:57 +00:00
CertificateExpiration time.Duration `json:"-"`
// body is the response body
//
// Note that this variable is only used during the evaluation of an Endpoint's health.
// This means that the call Endpoint.EvaluateHealth both populates the body (if necessary)
// and sets it to nil after the evaluation has been completed.
body []byte
2019-09-07 00:25:31 +00:00
}
2021-06-05 22:50:24 +00:00
// AddError adds an error to the result's list of errors.
// It also ensures that there are no duplicates.
func (r *Result) AddError(error string) {
for _, resultError := range r.Errors {
if resultError == error {
// If the error already exists, don't add it
return
}
}
r.Errors = append(r.Errors, error)
}