Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check struct {
Name string
Importance CheckImportance
Perform func() CheckResult
// contains filtered or unexported fields
}
Check represents an individual health check
func (*Check) StopCacheTicker ¶
func (c *Check) StopCacheTicker()
func (*Check) UpdateCache ¶
func (c *Check) UpdateCache()
type CheckFunc ¶
type CheckFunc func() (HealthStatus, error)
CheckFunc defines the signature for health check functions. Each health check function must conform to this signature to be registered and executed by the HealthChecker. The return values are as follows:
- HealthStatus: The status of the check, represented by predefined constants (StatusPass, StatusWarn, StatusFail). This indicates the health of the component being checked.
- error: An error value that should be nil if the check was successful, or provide error details if the check failed.
type CheckImportance ¶
type CheckImportance string
const ( // Required should be used when a check should be always ok Required CheckImportance = "required" // Optional can be used when a check is not required to be everytime ok, but if it fails then it not make the application fail Optional CheckImportance = "optional" // Info should be used when the check doesn't directly impact the operational status Info CheckImportance = "info" )
type CheckResult ¶
type CheckResult struct {
Name string `json:"name"`
Status HealthStatus `json:"status"`
ObservationTS time.Time `json:"observation_ts"`
}
CheckResult represents the result of a health check
type HealthCheckResponse ¶
type HealthCheckResponse struct {
Status HealthStatus `json:"status"`
StatusCode int `json:"status_code"`
Components []CheckResult `json:"components,omitempty"`
}
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker manages a set of checks
func NewHealthChecker ¶
func NewHealthChecker() *HealthChecker
func (*HealthChecker) HTTPHandler ¶
func (hc *HealthChecker) HTTPHandler() http.HandlerFunc
func (*HealthChecker) PerformChecks ¶
func (hc *HealthChecker) PerformChecks() HealthCheckResponse
func (*HealthChecker) RegisterCheck ¶
func (hc *HealthChecker) RegisterCheck(name string, importance CheckImportance, checkFunc CheckFunc) *Check
type HealthStatus ¶
type HealthStatus string
const ( StatusPass HealthStatus = "pass" StatusWarn HealthStatus = "warn" StatusFail HealthStatus = "fail" )
Click to show internal directories.
Click to hide internal directories.