Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Started is true once the app has initialized successfully (DB connected, etc.). Started atomic.Bool // Ready is true once the server is accepting traffic (Fiber listening / NATS subscribed). Ready atomic.Bool )
Probe flags for Kubernetes. Set by the application lifecycle (main.go).
var ErrServiceIsOffline = errors.New("service is offline")
ErrServiceIsOffline indicates that a health check dependency is offline.
Functions ¶
func AddHealthCheck ¶
func AddHealthCheck(f func() error)
AddHealthCheck registers a function called on /healthz, /readyz, and /livez. If any check returns an error the service is considered unhealthy.
func CheckHealth ¶
func CheckHealth() error
CheckHealth runs every registered health check concurrently and returns a joined error if any fail. Exported so the main app server can expose /healthz on the Traefik-facing port without auth.
func ExecuteHealthCheck ¶
func ExecuteHealthCheck() error
ExecuteHealthCheck runs every registered health check.
func Monitor ¶
func Monitor(addr string) func()
Monitor starts a standalone HTTP server on addr exposing health probes and pprof. It should be called as early as possible in main(), before DB/NATS/app init. Returns a shutdown function that should be deferred.
Usage:
shutdown := profiler.Monitor(":8011")
defer shutdown()
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
State owns profiler health checks and probe flags.
func DefaultState ¶
func DefaultState() *State
DefaultState returns the package-level compatibility profiler state.
func (*State) AddHealthCheck ¶
AddHealthCheck registers a function called on /healthz, /readyz, and /livez. If any check returns an error the service is considered unhealthy.
func (*State) CheckHealth ¶
CheckHealth runs every registered health check concurrently and returns a joined error if any fail.
func (*State) SetStarted ¶
SetStarted stores the startup probe flag.