 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- type AdvancedCheckFunc
- type AdvancedCheckResult
- type AdvancedCheckerConfig
- type AdvancedHealthChecker
- func (hc *AdvancedHealthChecker) CheckAdvancedHealth(ctx context.Context) *AdvancedHealthResult
- func (hc *AdvancedHealthChecker) CloseAdvanced() error
- func (hc *AdvancedHealthChecker) GetAdvancedLastResult() *AdvancedHealthResult
- func (hc *AdvancedHealthChecker) HTTPAdvancedHandler() http.HandlerFunc
- func (hc *AdvancedHealthChecker) RegisterAdvancedCheck(name string, checkFunc AdvancedCheckFunc)
 
- type AdvancedHealthResult
- type AdvancedHealthSummary
- type AdvancedStatus
- type AdvancedSystemInfo
- 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 GCStats
- 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 HealthAlert
- type HealthChecker
- type HealthMetricsCollector
- type HealthResponse
- type HealthTrend
- type ResourceUsage
- type RuntimeInfo
- type Severity
- type Status
- type SystemInfo
- type TrendAnalyzer
- type TrendDataPoint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdvancedCheckFunc ¶ added in v1.0.2
type AdvancedCheckFunc func(ctx context.Context, metadata map[string]interface{}) *AdvancedCheckResult
AdvancedCheckFunc representa una función de health check mejorada
type AdvancedCheckResult ¶ added in v1.0.2
type AdvancedCheckResult struct {
	Name        string                 `json:"name"`
	Status      AdvancedStatus         `json:"status"`
	Message     string                 `json:"message,omitempty"`
	Error       string                 `json:"error,omitempty"`
	Duration    time.Duration          `json:"duration"`
	Timestamp   time.Time              `json:"timestamp"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
	Critical    bool                   `json:"critical"`
	Timeout     time.Duration          `json:"timeout"`
	LastSuccess time.Time              `json:"last_success,omitempty"`
	// Campos extendidos para gopherkit
	Severity        Severity           `json:"severity"`
	Component       string             `json:"component"`
	Category        string             `json:"category"`
	Recommendations []string           `json:"recommendations,omitempty"`
	Dependencies    []string           `json:"dependencies,omitempty"`
	Metrics         map[string]float64 `json:"metrics,omitempty"`
	Trend           HealthTrend        `json:"trend,omitempty"`
	RetryCount      int                `json:"retry_count,omitempty"`
	MaxRetries      int                `json:"max_retries,omitempty"`
}
    AdvancedCheckResult representa el resultado de un health check con información extendida
type AdvancedCheckerConfig ¶ added in v1.0.2
type AdvancedCheckerConfig struct {
	ServiceName    string
	DatabaseMode   string
	DatabaseSchema string
	DatabaseURL    string
	RedisURL       string
	RedisNamespace string
	DefaultTimeout time.Duration
	CriticalChecks []string
	Metadata       map[string]interface{}
	// Configuración extendida
	Environment             string
	EnableTrendAnalysis     bool
	EnableSystemInfo        bool
	EnableRecommendations   bool
	EnablePrometheusMetrics bool
	MaxHistoryEntries       int
	CheckInterval           time.Duration
	ParallelCheckLimit      int
	// Integración con gopherkit
	BaseConfig   *config.BaseConfig
	AlertManager *monitoring.AlertManager
}
    AdvancedCheckerConfig mantiene la configuración del health checker avanzado
func LoadAdvancedConfigFromBase ¶ added in v1.0.2
func LoadAdvancedConfigFromBase(baseConfig *config.BaseConfig, serviceName string) *AdvancedCheckerConfig
LoadAdvancedConfigFromBase carga configuración avanzada desde BaseConfig de gopherkit
func LoadAdvancedDefaultConfig ¶ added in v1.0.2
func LoadAdvancedDefaultConfig() *AdvancedCheckerConfig
LoadAdvancedDefaultConfig carga configuración por defecto avanzada
type AdvancedHealthChecker ¶ added in v1.0.2
type AdvancedHealthChecker struct {
	// contains filtered or unexported fields
}
    AdvancedHealthChecker realiza health checks con funcionalidades avanzadas
func NewAdvancedHealthChecker ¶ added in v1.0.2
func NewAdvancedHealthChecker(config *AdvancedCheckerConfig, db *sql.DB, redisClient *redis.Client) *AdvancedHealthChecker
NewAdvancedHealthChecker crea un nuevo health checker con funcionalidades avanzadas
func (*AdvancedHealthChecker) CheckAdvancedHealth ¶ added in v1.0.2
func (hc *AdvancedHealthChecker) CheckAdvancedHealth(ctx context.Context) *AdvancedHealthResult
CheckAdvancedHealth realiza todos los health checks avanzados
func (*AdvancedHealthChecker) CloseAdvanced ¶ added in v1.0.2
func (hc *AdvancedHealthChecker) CloseAdvanced() error
CloseAdvanced cierra el health checker avanzado de forma graciosa
func (*AdvancedHealthChecker) GetAdvancedLastResult ¶ added in v1.0.2
func (hc *AdvancedHealthChecker) GetAdvancedLastResult() *AdvancedHealthResult
GetAdvancedLastResult retorna el último resultado de health check avanzado
func (*AdvancedHealthChecker) HTTPAdvancedHandler ¶ added in v1.0.2
func (hc *AdvancedHealthChecker) HTTPAdvancedHandler() http.HandlerFunc
HTTPAdvancedHandler retorna un handler HTTP para health checks avanzados
func (*AdvancedHealthChecker) RegisterAdvancedCheck ¶ added in v1.0.2
func (hc *AdvancedHealthChecker) RegisterAdvancedCheck(name string, checkFunc AdvancedCheckFunc)
RegisterAdvancedCheck registra un nuevo health check avanzado
type AdvancedHealthResult ¶ added in v1.0.2
type AdvancedHealthResult struct {
	Status    AdvancedStatus                  `json:"status"`
	Timestamp time.Time                       `json:"timestamp"`
	Duration  time.Duration                   `json:"duration"`
	Checks    map[string]*AdvancedCheckResult `json:"checks"`
	Metadata  map[string]interface{}          `json:"metadata,omitempty"`
	Version   string                          `json:"version,omitempty"`
	Service   string                          `json:"service"`
	Mode      string                          `json:"mode"`
	// Campos extendidos
	Environment     string                 `json:"environment"`
	OverallSeverity Severity               `json:"overall_severity"`
	Summary         AdvancedHealthSummary  `json:"summary"`
	SystemInfo      AdvancedSystemInfo     `json:"system_info"`
	Alerts          []HealthAlert          `json:"alerts,omitempty"`
	Recommendations []string               `json:"recommendations,omitempty"`
	TrendAnalysis   map[string]HealthTrend `json:"trend_analysis,omitempty"`
}
    AdvancedHealthResult representa el resultado general de health checks con funcionalidades avanzadas
type AdvancedHealthSummary ¶ added in v1.0.2
type AdvancedHealthSummary struct {
	TotalChecks    int              `json:"total_checks"`
	HealthyChecks  int              `json:"healthy_checks"`
	CriticalIssues int              `json:"critical_issues"`
	Warnings       int              `json:"warnings"`
	ByCategory     map[string]int   `json:"by_category"`
	BySeverity     map[Severity]int `json:"by_severity"`
	UpTime         time.Duration    `json:"uptime"`
	LastRestart    time.Time        `json:"last_restart,omitempty"`
}
    AdvancedHealthSummary proporciona un resumen ejecutivo del estado de salud
type AdvancedStatus ¶ added in v1.0.2
type AdvancedStatus string
Status representa el estado de salud de un componente con estados extendidos
const ( AdvancedStatusHealthy AdvancedStatus = "healthy" AdvancedStatusUnhealthy AdvancedStatus = "unhealthy" AdvancedStatusDegraded AdvancedStatus = "degraded" AdvancedStatusUnknown AdvancedStatus = "unknown" AdvancedStatusMaintenance AdvancedStatus = "maintenance" AdvancedStatusWarning AdvancedStatus = "warning" AdvancedStatusCritical AdvancedStatus = "critical" AdvancedStatusRecovering AdvancedStatus = "recovering" )
type AdvancedSystemInfo ¶ added in v1.0.2
type AdvancedSystemInfo struct {
	GoVersion     string            `json:"go_version"`
	Runtime       RuntimeInfo       `json:"runtime"`
	Dependencies  map[string]string `json:"dependencies"`
	Configuration map[string]string `json:"configuration"`
	Resources     ResourceUsage     `json:"resources"`
	Capabilities  []string          `json:"capabilities"`
}
    AdvancedSystemInfo proporciona información extendida del sistema
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 GCStats ¶ added in v1.0.2
type GCStats struct {
	NextGC       uint64    `json:"next_gc"`
	LastGC       time.Time `json:"last_gc"`
	PauseTotalNs uint64    `json:"pause_total_ns"`
	NumGC        uint32    `json:"num_gc"`
	GCPercent    int       `json:"gc_percent"`
}
    GCStats estadísticas del garbage collector
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 HealthAlert ¶ added in v1.0.2
type HealthAlert struct {
	ID         string                 `json:"id"`
	Level      string                 `json:"level"`
	Message    string                 `json:"message"`
	Component  string                 `json:"component"`
	Timestamp  time.Time              `json:"timestamp"`
	Resolved   bool                   `json:"resolved"`
	ResolvedAt *time.Time             `json:"resolved_at,omitempty"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}
    HealthAlert representa una alerta de salud
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 HealthMetricsCollector ¶ added in v1.0.2
type HealthMetricsCollector struct {
	// contains filtered or unexported fields
}
    HealthMetricsCollector recopila métricas de salud para Prometheus
func NewHealthMetricsCollector ¶ added in v1.0.2
func NewHealthMetricsCollector(serviceName string) *HealthMetricsCollector
func (*HealthMetricsCollector) RecordAdvancedHealthCheck ¶ added in v1.0.2
func (hmc *HealthMetricsCollector) RecordAdvancedHealthCheck(result *AdvancedHealthResult)
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 HealthTrend ¶ added in v1.0.2
type HealthTrend struct {
	Direction    string             `json:"direction"` // "improving", "declining", "stable"
	Confidence   float64            `json:"confidence"`
	DataPoints   int                `json:"data_points"`
	LastUpdated  time.Time          `json:"last_updated"`
	TrendMetrics map[string]float64 `json:"trend_metrics,omitempty"`
}
    HealthTrend representa la tendencia de salud de un componente
type ResourceUsage ¶ added in v1.0.2
type ResourceUsage struct {
	MemoryUsageMB   float64   `json:"memory_usage_mb"`
	CPUUsagePercent float64   `json:"cpu_usage_percent"`
	DiskUsageMB     float64   `json:"disk_usage_mb"`
	NetworkBytesIn  uint64    `json:"network_bytes_in"`
	NetworkBytesOut uint64    `json:"network_bytes_out"`
	LastUpdated     time.Time `json:"last_updated"`
}
    ResourceUsage información de uso de recursos
type RuntimeInfo ¶ added in v1.0.2
type RuntimeInfo struct {
	NumGoroutines int              `json:"num_goroutines"`
	NumCPU        int              `json:"num_cpu"`
	MemStats      runtime.MemStats `json:"mem_stats"`
	GCStats       GCStats          `json:"gc_stats"`
}
    RuntimeInfo información del runtime de Go
type Severity ¶ added in v1.0.2
type Severity int
Severity define la severidad de un problema de salud
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
type TrendAnalyzer ¶ added in v1.0.2
type TrendAnalyzer struct {
	// contains filtered or unexported fields
}
    TrendAnalyzer analiza tendencias de salud a lo largo del tiempo
func NewTrendAnalyzer ¶ added in v1.0.2
func NewTrendAnalyzer(maxDataPoints int, analysisWindow time.Duration) *TrendAnalyzer
func (*TrendAnalyzer) AddAdvancedDataPoint ¶ added in v1.0.2
func (ta *TrendAnalyzer) AddAdvancedDataPoint(result *AdvancedHealthResult)
func (*TrendAnalyzer) AnalyzeAdvancedTrends ¶ added in v1.0.2
func (ta *TrendAnalyzer) AnalyzeAdvancedTrends() map[string]HealthTrend
type TrendDataPoint ¶ added in v1.0.2
type TrendDataPoint struct {
	Timestamp time.Time
	Status    AdvancedStatus
	Duration  time.Duration
	Metrics   map[string]float64
}
    TrendDataPoint representa un punto de datos para análisis de tendencias