health

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrokerRegistry

type BrokerRegistry interface {
	GetBrokerCount() int
	GetActiveBrokerCount() int
}

BrokerRegistry interface for health checking

type BrokerRegistryHealthChecker

type BrokerRegistryHealthChecker struct {
	// contains filtered or unexported fields
}

BrokerRegistryHealthChecker checks broker registry health

func NewBrokerRegistryHealthChecker

func NewBrokerRegistryHealthChecker(name string, registry BrokerRegistry) *BrokerRegistryHealthChecker

NewBrokerRegistryHealthChecker creates a health checker for broker registry

func (*BrokerRegistryHealthChecker) Check

Check performs the health check

func (*BrokerRegistryHealthChecker) Name

Name returns the checker name

type Check

type Check struct {
	Name      string                 `json:"name"`
	Status    Status                 `json:"status"`
	Message   string                 `json:"message,omitempty"`
	Timestamp time.Time              `json:"timestamp"`
	Duration  time.Duration          `json:"duration_ms"`
	Details   map[string]interface{} `json:"details,omitempty"`
}

Check represents a health check result for a component

func LivenessCheck

func LivenessCheck() Check

LivenessCheck returns a simple check that always succeeds (process is alive)

type Checker

type Checker interface {
	// Name returns the name of this health check
	Name() string
	// Check performs the health check and returns the result
	Check(ctx context.Context) Check
}

Checker is the interface that health check providers must implement

type ClusterCoordinator

type ClusterCoordinator interface {
	GetRebalanceStats() RebalanceStats
	GetCurrentAssignment() CurrentAssignment
}

ClusterCoordinator interface for health checking

type ComponentHealthChecker

type ComponentHealthChecker struct {
	// contains filtered or unexported fields
}

ComponentHealthChecker aggregates multiple health checks

func NewComponentHealthChecker

func NewComponentHealthChecker(name string, checkers ...Checker) *ComponentHealthChecker

NewComponentHealthChecker creates a checker that aggregates multiple checks

func (*ComponentHealthChecker) Check

Check runs all component checks and aggregates the result

func (*ComponentHealthChecker) Name

func (c *ComponentHealthChecker) Name() string

Name returns the checker name

type CoordinatorHealthChecker

type CoordinatorHealthChecker struct {
	// contains filtered or unexported fields
}

CoordinatorHealthChecker checks cluster coordinator health

func NewCoordinatorHealthChecker

func NewCoordinatorHealthChecker(name string, coordinator ClusterCoordinator) *CoordinatorHealthChecker

NewCoordinatorHealthChecker creates a health checker for the coordinator

func (*CoordinatorHealthChecker) Check

Check performs the health check

func (*CoordinatorHealthChecker) Name

func (c *CoordinatorHealthChecker) Name() string

Name returns the checker name

type CurrentAssignment

type CurrentAssignment interface {
	TotalPartitions() int
}

CurrentAssignment represents the current partition assignment

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler provides HTTP handlers for health check endpoints

func NewHandler

func NewHandler(registry *Registry) *Handler

NewHandler creates a new HTTP handler for health checks

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers all health check routes on the given mux

type MetadataState

type MetadataState interface {
	GetVersion() uint64
	GetBrokerCount() int
	GetPartitionCount() int
}

MetadataState represents the metadata state

type MetadataStore

type MetadataStore interface {
	IsLeader() bool
	GetState() MetadataState
}

MetadataStore interface for health checking

type MetadataStoreHealthChecker

type MetadataStoreHealthChecker struct {
	// contains filtered or unexported fields
}

MetadataStoreHealthChecker checks metadata store health

func NewMetadataStoreHealthChecker

func NewMetadataStoreHealthChecker(name string, store MetadataStore) *MetadataStoreHealthChecker

NewMetadataStoreHealthChecker creates a health checker for metadata store

func (*MetadataStoreHealthChecker) Check

Check performs the health check

func (*MetadataStoreHealthChecker) Name

Name returns the checker name

type PeriodicChecker

type PeriodicChecker struct {
	// contains filtered or unexported fields
}

PeriodicChecker runs health checks periodically and caches results

func NewPeriodicChecker

func NewPeriodicChecker(checker Checker, interval time.Duration) *PeriodicChecker

NewPeriodicChecker creates a health checker that runs periodically

func (*PeriodicChecker) Check

func (pc *PeriodicChecker) Check(ctx context.Context) Check

Check returns the last cached health check result

func (*PeriodicChecker) Name

func (pc *PeriodicChecker) Name() string

Name returns the wrapped checker name

func (*PeriodicChecker) Start

func (pc *PeriodicChecker) Start()

Start begins periodic health checking

func (*PeriodicChecker) Stop

func (pc *PeriodicChecker) Stop()

Stop stops periodic health checking

type RaftNode

type RaftNode interface {
	IsLeader() bool
	Leader() uint64
}

RaftNode is the interface for checking Raft node health

type RaftNodeHealthChecker

type RaftNodeHealthChecker struct {
	// contains filtered or unexported fields
}

RaftNodeHealthChecker checks the health of a Raft consensus node

func NewRaftNodeHealthChecker

func NewRaftNodeHealthChecker(name string, node RaftNode) *RaftNodeHealthChecker

NewRaftNodeHealthChecker creates a health checker for a Raft node

func (*RaftNodeHealthChecker) Check

Check performs the health check

func (*RaftNodeHealthChecker) Name

func (r *RaftNodeHealthChecker) Name() string

Name returns the checker name

type RebalanceStats

type RebalanceStats interface {
	IsRebalancing() bool
	GetLastRebalanceTime() time.Time
	GetRebalanceCount() int64
	GetFailedRebalances() int64
}

RebalanceStats represents rebalancing statistics

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages health checks

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new health check registry

func (*Registry) CheckAll

func (r *Registry) CheckAll(ctx context.Context) Response

CheckAll runs all registered health checks and returns aggregated results

func (*Registry) CheckOne

func (r *Registry) CheckOne(ctx context.Context, name string) (Check, error)

CheckOne runs a single health check by name

func (*Registry) ReadinessCheck

func (r *Registry) ReadinessCheck(ctx context.Context) Check

ReadinessCheck returns the aggregated status for readiness A system is ready if all critical components are healthy or degraded (not unhealthy)

func (*Registry) Register

func (r *Registry) Register(checker Checker)

Register adds a health checker to the registry

func (*Registry) SetTimeout

func (r *Registry) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for health checks

func (*Registry) Unregister

func (r *Registry) Unregister(name string)

Unregister removes a health checker from the registry

type Response

type Response struct {
	Status    Status           `json:"status"`
	Timestamp time.Time        `json:"timestamp"`
	Checks    map[string]Check `json:"checks"`
}

Response represents the aggregated health check response

func (*Response) MarshalJSON

func (r *Response) MarshalJSON() ([]byte, error)

MarshalJSON customizes JSON marshaling for Response

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server wraps an HTTP server for health checks

func NewServer

func NewServer(addr string, registry *Registry) *Server

NewServer creates a new health check HTTP server

func (*Server) Start

func (s *Server) Start() error

Start starts the health check server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully stops the health check server

type SimpleChecker

type SimpleChecker struct {
	// contains filtered or unexported fields
}

SimpleChecker is a basic implementation of Checker using a function

func NewSimpleChecker

func NewSimpleChecker(name string, fn func(ctx context.Context) Check) *SimpleChecker

NewSimpleChecker creates a new simple health checker

func (*SimpleChecker) Check

func (sc *SimpleChecker) Check(ctx context.Context) Check

Check executes the health check function

func (*SimpleChecker) Name

func (sc *SimpleChecker) Name() string

Name returns the checker name

type Status

type Status string

Status represents the health status of a component

const (
	// StatusHealthy indicates the component is healthy
	StatusHealthy Status = "healthy"
	// StatusDegraded indicates the component is working but not optimally
	StatusDegraded Status = "degraded"
	// StatusUnhealthy indicates the component is not working
	StatusUnhealthy Status = "unhealthy"
	// StatusUnknown indicates the health status is unknown
	StatusUnknown Status = "unknown"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL