2024-05-10 04:56:16 +02:00
|
|
|
package endpoint
|
2019-09-07 02:25:31 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2021-10-23 22:47:12 +02:00
|
|
|
// Result of the evaluation of a Endpoint
|
2019-09-07 02:25:31 +02:00
|
|
|
type Result struct {
|
2020-10-23 22:29:20 +02:00
|
|
|
// HTTPStatus is the HTTP response status code
|
2024-04-09 03:00:40 +02:00
|
|
|
HTTPStatus int `json:"status,omitempty"`
|
2020-10-05 01:49:02 +02:00
|
|
|
|
2021-10-23 22:47:12 +02:00
|
|
|
// DNSRCode is the response code of a DNS query in a human-readable format
|
2022-06-17 00:50:40 +02:00
|
|
|
//
|
|
|
|
// Possible values: NOERROR, FORMERR, SERVFAIL, NXDOMAIN, NOTIMP, REFUSED
|
2020-11-30 15:40:57 +01:00
|
|
|
DNSRCode string `json:"-"`
|
2020-11-18 00:55:31 +01:00
|
|
|
|
2021-10-23 22:47:12 +02:00
|
|
|
// Hostname extracted from Endpoint.URL
|
2021-11-04 03:18:23 +01:00
|
|
|
Hostname string `json:"hostname,omitempty"`
|
2020-10-05 01:49:02 +02:00
|
|
|
|
2021-10-23 22:47:12 +02:00
|
|
|
// IP resolved from the Endpoint URL
|
2020-10-23 22:29:20 +02:00
|
|
|
IP string `json:"-"`
|
2020-10-05 01:49:02 +02:00
|
|
|
|
|
|
|
// Connected whether a connection to the host was established successfully
|
|
|
|
Connected bool `json:"-"`
|
|
|
|
|
|
|
|
// Duration time that the request took
|
|
|
|
Duration time.Duration `json:"duration"`
|
|
|
|
|
2021-10-23 22:47:12 +02:00
|
|
|
// Errors encountered during the evaluation of the Endpoint's health
|
2021-11-04 03:18:23 +01:00
|
|
|
Errors []string `json:"errors,omitempty"`
|
2020-10-05 01:49:02 +02:00
|
|
|
|
2024-05-05 02:05:06 +02:00
|
|
|
// ConditionResults are the results of each of the Endpoint's Condition
|
2024-04-09 03:00:40 +02:00
|
|
|
ConditionResults []*ConditionResult `json:"conditionResults,omitempty"`
|
2020-10-05 01:49:02 +02:00
|
|
|
|
|
|
|
// Success whether the result signifies a success or not
|
|
|
|
Success bool `json:"success"`
|
|
|
|
|
|
|
|
// Timestamp when the request was sent
|
|
|
|
Timestamp time.Time `json:"timestamp"`
|
2020-11-15 18:33:09 +01:00
|
|
|
|
|
|
|
// CertificateExpiration is the duration before the certificate expires
|
2020-11-30 15:40:57 +01:00
|
|
|
CertificateExpiration time.Duration `json:"-"`
|
2021-03-09 03:30:11 +01:00
|
|
|
|
2022-09-07 03:22:02 +02:00
|
|
|
// DomainExpiration is the duration before the domain expires
|
|
|
|
DomainExpiration time.Duration `json:"-"`
|
|
|
|
|
2023-03-15 01:02:31 +01:00
|
|
|
// Body is the response body
|
2021-03-09 03:30:11 +01:00
|
|
|
//
|
2023-03-15 01:02:31 +01:00
|
|
|
// Note that this field is not persisted in the storage.
|
|
|
|
// It is used for health evaluation as well as debugging purposes.
|
|
|
|
Body []byte `json:"-"`
|
2019-09-07 02:25:31 +02:00
|
|
|
}
|
2021-06-06 00:50:24 +02: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)
|
|
|
|
}
|