 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- type CheckResult
- type Checker
- func (c *Checker) AddChecker(checker HealthChecker)
- func (c *Checker) Check(ctx context.Context) HealthResponse
- func (c *Checker) GetComponentStatus(ctx context.Context, componentName string) (ComponentHealth, bool)
- func (c *Checker) GetServiceInfo() map[string]interface{}
- func (c *Checker) IsHealthy(ctx context.Context) bool
- func (c *Checker) IsLive(ctx context.Context) bool
- func (c *Checker) IsReady(ctx context.Context) bool
- func (c *Checker) ListComponents() []string
 
- type CheckerOption
- type ComponentHealth
- type Handler
- func (h *Handler) Component(c *gin.Context)
- func (h *Handler) Components(c *gin.Context)
- func (h *Handler) Health(c *gin.Context)
- func (h *Handler) Info(c *gin.Context)
- func (h *Handler) Liveness(c *gin.Context)
- func (h *Handler) Middleware() gin.HandlerFunc
- func (h *Handler) Readiness(c *gin.Context)
- func (h *Handler) RegisterRoutes(router gin.IRouter)
 
- type HealthChecker
- type HealthResponse
- type Status
- type SystemInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
type CheckResult struct {
	Name   string
	Health ComponentHealth
	Error  error
}
    CheckResult representa el resultado de un health check individual
type Checker ¶
type Checker struct {
	// contains filtered or unexported fields
}
    Checker agregado que combina múltiples health checkers
func NewChecker ¶
func NewChecker(service, version string, opts ...CheckerOption) *Checker
NewChecker crea un nuevo health checker agregado
func (*Checker) AddChecker ¶
func (c *Checker) AddChecker(checker HealthChecker)
AddChecker añade un health checker
func (*Checker) Check ¶
func (c *Checker) Check(ctx context.Context) HealthResponse
Check ejecuta todos los health checks
func (*Checker) GetComponentStatus ¶
func (c *Checker) GetComponentStatus(ctx context.Context, componentName string) (ComponentHealth, bool)
GetComponentStatus obtiene el estado de un componente específico
func (*Checker) GetServiceInfo ¶
GetServiceInfo retorna información básica del servicio
func (*Checker) ListComponents ¶
ListComponents retorna la lista de nombres de componentes
type CheckerOption ¶
type CheckerOption func(*Checker)
CheckerOption define opciones para configurar el Checker
func WithBuildInfo ¶
func WithBuildInfo(buildTime, gitCommit string) CheckerOption
WithBuildInfo configura información de build
func WithEnvironment ¶
func WithEnvironment(env string) CheckerOption
WithEnvironment configura el environment
type ComponentHealth ¶
type ComponentHealth struct {
	Status      Status                 `json:"status"`
	Message     string                 `json:"message,omitempty"`
	Timestamp   time.Time              `json:"timestamp"`
	Duration    time.Duration          `json:"duration"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
	Error       string                 `json:"error,omitempty"`
	LastChecked time.Time              `json:"last_checked"`
}
    ComponentHealth representa la salud de un componente individual
func NewComponentHealth ¶
func NewComponentHealth(status Status, message string) ComponentHealth
NewComponentHealth crea un nuevo ComponentHealth
func (ComponentHealth) WithDuration ¶
func (c ComponentHealth) WithDuration(duration time.Duration) ComponentHealth
WithDuration añade duración al ComponentHealth
func (ComponentHealth) WithError ¶
func (c ComponentHealth) WithError(err error) ComponentHealth
WithError añade un error al ComponentHealth
func (ComponentHealth) WithMetadata ¶
func (c ComponentHealth) WithMetadata(key string, value interface{}) ComponentHealth
WithMetadata añade metadata al ComponentHealth
type Handler ¶
type Handler struct {
	// contains filtered or unexported fields
}
    Handler maneja las rutas de health check
func NewHandler ¶
NewHandler crea un nuevo handler de health checks
func (*Handler) Component ¶
Component maneja GET /health/component/{name} - health check de componente específico
func (*Handler) Components ¶
Components maneja GET /health/components - lista todos los componentes
func (*Handler) Middleware ¶
func (h *Handler) Middleware() gin.HandlerFunc
Middleware crea un middleware que registra health check requests
func (*Handler) RegisterRoutes ¶
RegisterRoutes registra todas las rutas de health check en un router Gin
type HealthChecker ¶
type HealthChecker interface {
	// Name retorna el nombre del componente
	Name() string
	// Check ejecuta el health check
	Check(ctx context.Context) ComponentHealth
	// IsRequired indica si este componente es requerido para la salud general
	IsRequired() bool
	// Timeout retorna el timeout para este health check
	Timeout() time.Duration
}
    HealthChecker define la interfaz para health checkers
type HealthResponse ¶
type HealthResponse struct {
	Status      Status                     `json:"status"`
	Service     string                     `json:"service"`
	Version     string                     `json:"version"`
	Timestamp   time.Time                  `json:"timestamp"`
	Uptime      time.Duration              `json:"uptime"`
	Components  map[string]ComponentHealth `json:"components"`
	SystemInfo  SystemInfo                 `json:"system_info"`
	RequestID   string                     `json:"request_id,omitempty"`
	Environment string                     `json:"environment,omitempty"`
}
    HealthResponse representa la respuesta completa de health check
type Status ¶
type Status string
Status representa el estado de salud de un componente
func OverallStatus ¶
func OverallStatus(components map[string]ComponentHealth) Status
OverallStatus calcula el estado general basado en los componentes
type SystemInfo ¶
type SystemInfo struct {
	Version     string    `json:"version"`
	BuildTime   string    `json:"build_time,omitempty"`
	GitCommit   string    `json:"git_commit,omitempty"`
	GoVersion   string    `json:"go_version"`
	Platform    string    `json:"platform"`
	StartTime   time.Time `json:"start_time"`
	Uptime      string    `json:"uptime"`
	Environment string    `json:"environment,omitempty"`
}
    SystemInfo representa información del sistema