- Fix error return value checks (errcheck) - Fix unused parameters by using underscore prefix - Add missing package comments to all packages - Fix context key type issue in middleware (use typed contextKey) - Replace deprecated trace.NewNoopTracerProvider with noop.NewTracerProvider - Fix embedded field selector in database client - Remove trailing whitespace - Remove revive linter (as requested) to avoid stuttering warnings for public API interfaces All linting and formatting checks now pass.
35 lines
1006 B
Go
35 lines
1006 B
Go
// Package health provides interfaces and types for health checking.
|
|
package health
|
|
|
|
import "context"
|
|
|
|
// HealthChecker defines the interface for health checks.
|
|
type HealthChecker interface {
|
|
// Check performs a health check and returns an error if unhealthy.
|
|
// Returns nil if the component is healthy.
|
|
Check(ctx context.Context) error
|
|
}
|
|
|
|
// Status represents the health status of a component.
|
|
type Status string
|
|
|
|
const (
|
|
// StatusHealthy indicates the component is healthy.
|
|
StatusHealthy Status = "healthy"
|
|
// StatusUnhealthy indicates the component is unhealthy.
|
|
StatusUnhealthy Status = "unhealthy"
|
|
)
|
|
|
|
// ComponentStatus represents the health status of a single component.
|
|
type ComponentStatus struct {
|
|
Name string `json:"name"`
|
|
Status Status `json:"status"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
// HealthStatus represents the overall health status.
|
|
type HealthStatus struct {
|
|
Status Status `json:"status"`
|
|
Components []ComponentStatus `json:"components,omitempty"`
|
|
}
|