Documentation
¶
Overview ¶
Package check provides the implementations of the health checks for the flipper service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPCheck ¶
type HTTPCheck struct {
// contains filtered or unexported fields
}
HTTPCheck checks the health of a resource over HTTP or HTTPS.
func NewHTTPCheck ¶
func NewHTTPCheck(cfg cfgmodel.HealthCheckConfig, target string) *HTTPCheck
NewHTTPCheck creates a new HTTP or HTTPS health check from a config. The target is generally the IP address of the resource being checked, although it could also be a hostname.
func (*HTTPCheck) Check ¶
func (h *HTTPCheck) Check(ctx context.Context) HTTPCheckResult
Check the health of a resource at the given IP address by performing a HTTP request.
func (*HTTPCheck) Config ¶
func (h *HTTPCheck) Config() cfgmodel.HealthCheckConfig
Config returns the health check configuration.
type HTTPCheckResult ¶
type HTTPCheckResult struct { // Error is the error that occurred during the check, or nil if the check was successful. Error error // StatusCode is the HTTP status code of the response. StatusCode int // Duration is the time it took to perform the check. TLS TLSCertificatesResult }
HTTPCheckResult is the result of a HTTP health check.
func (HTTPCheckResult) Errorf ¶
func (r HTTPCheckResult) Errorf(fmtString string, args ...any) HTTPCheckResult
Errorf sets the error of the result, it's a convenience method to set the error with a formatted string.
func (HTTPCheckResult) Healthy ¶
func (r HTTPCheckResult) Healthy() bool
Healthy returns true if the check is healthy.
type Result ¶
type Result interface { // Healthy returns true if the check is healthy. Healthy() bool }
Result is the result of a health check.
type TLSCertificatesResult ¶
type TLSCertificatesResult struct { // IsTLS is true if the connection is using TLS. IsTLS bool // NotAfter is the expiration date of the certificate. NotAfter time.Time // NotBefore is the start date of the certificate. NotBefore time.Time // DNSNames is a list of DNS names in the certificate. DNSNames []string }
TLSCertificatesResult represents the result of a TLS certificate check. It only considers the leaf certificate - which is generally the one that matters.
func TLSCertificatesResultFromConnectionState ¶
func TLSCertificatesResultFromConnectionState(s *tls.ConnectionState) TLSCertificatesResult
TLSCertificatesResultFromConnectionState creates a TLSCeriticatesResult from a tls.ConnectionState.
func (TLSCertificatesResult) ExpiresWithin ¶
func (r TLSCertificatesResult) ExpiresWithin(d time.Duration) bool
ExpiresWithin returns true if the certificate expires within the given duration.