Documentation
¶
Overview ¶
Package health provides comprehensive health checking for Gitea services.
Index ¶
- type Checker
- func NewCacheChecker(pingFunc func(ctx context.Context) error) Checker
- func NewDatabaseChecker(pingFunc func(ctx context.Context) error) Checker
- func NewExternalServiceChecker(name string, checkFunc func(ctx context.Context) error) Checker
- func NewGitChecker(checkFunc func(ctx context.Context) (string, error)) Checker
- func NewQueueChecker(getQueueStats func() (pending, processing int)) Checker
- func NewSSHChecker(isEnabled bool, port int) Checker
- type ComponentCheck
- type Manager
- func (m *Manager) Check(ctx context.Context, includeSystem bool) *Response
- func (m *Manager) CheckSingle(ctx context.Context, name string) (*ComponentCheck, bool)
- func (m *Manager) LivenessCheck() *ComponentCheck
- func (m *Manager) ReadinessCheck(ctx context.Context) *Response
- func (m *Manager) RegisterChecker(name string, checker Checker)
- func (m *Manager) UnregisterChecker(name string)
- type Response
- type Status
- type SystemInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker func(ctx context.Context) *ComponentCheck
Checker is a function that performs a health check
func NewCacheChecker ¶
NewCacheChecker creates a cache health checker
func NewDatabaseChecker ¶
NewDatabaseChecker creates a database health checker
func NewExternalServiceChecker ¶
NewExternalServiceChecker creates a checker for external services
func NewGitChecker ¶
NewGitChecker creates a git service health checker
func NewQueueChecker ¶
NewQueueChecker creates a checker for the task queue
type ComponentCheck ¶
type ComponentCheck struct {
Name string `json:"name"`
Status Status `json:"status"`
Message string `json:"message,omitempty"`
Duration time.Duration `json:"duration_ms"`
LastChecked time.Time `json:"last_checked"`
Metadata map[string]any `json:"metadata,omitempty"`
}
ComponentCheck represents a health check for a single component
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages health checks
func (*Manager) Check ¶
Check performs all health checks
func (*Manager) CheckSingle ¶
CheckSingle performs a single component check
func (*Manager) LivenessCheck ¶
func (m *Manager) LivenessCheck() *ComponentCheck
LivenessCheck performs a quick liveness check (is the service running?)
func (*Manager) ReadinessCheck ¶
ReadinessCheck performs a readiness check (can the service handle requests?)
func (*Manager) RegisterChecker ¶
RegisterChecker registers a new health checker
type Response ¶
type Response struct {
Status Status `json:"status"`
Version string `json:"version"`
Uptime time.Duration `json:"uptime_seconds"`
Timestamp time.Time `json:"timestamp"`
Components map[string]*ComponentCheck `json:"components"`
System *SystemInfo `json:"system,omitempty"`
Circuits map[string]circuitbreaker.Stats `json:"circuit_breakers,omitempty"`
}
Response represents the complete health check response
type SystemInfo ¶
type SystemInfo struct {
GoVersion string `json:"go_version"`
NumGoroutines int `json:"goroutines"`
MemoryAllocMB float64 `json:"memory_alloc_mb"`
MemorySysMB float64 `json:"memory_sys_mb"`
NumCPU int `json:"num_cpu"`
GOMAXPROCS int `json:"gomaxprocs"`
}
SystemInfo contains system-level health information
Source Files
¶
- health.go