health

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name      string    `json:"name"`
	Status    string    `json:"status"`
	Message   string    `json:"message,omitempty"`
	Timestamp time.Time `json:"timestamp"`
}

type HandlerMux

type HandlerMux interface {
	Handle(pattern string, handler http.Handler)
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}

HandlerMux is the interface for registering HTTP handlers, used by RegisterOnMux so that callers can pass any mux implementation (e.g. *http.ServeMux or a custom dynamic mux).

type Server

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

func NewServer

func NewServer(host string, port int, token string) *Server

func (*Server) RegisterCheck

func (s *Server) RegisterCheck(name string, checkFn func() (bool, string))

func (*Server) RegisterOnMux

func (s *Server) RegisterOnMux(mux HandlerMux)

RegisterOnMux registers /health, /ready and /reload handlers onto the given mux. This allows the health endpoints to be served by a shared HTTP server.

func (*Server) SetReady

func (s *Server) SetReady(ready bool)

func (*Server) SetReloadFunc

func (s *Server) SetReloadFunc(fn func() error)

SetReloadFunc sets the callback function for config reload.

func (*Server) Start

func (s *Server) Start() error

func (*Server) StartContext

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

func (*Server) Stop

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

type StatusResponse

type StatusResponse struct {
	Status string           `json:"status"`
	Uptime string           `json:"uptime"`
	PID    int              `json:"pid,omitempty"`
	Checks map[string]Check `json:"checks,omitempty"`
}

Jump to

Keyboard shortcuts

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