profiler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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).

View Source
var ErrServiceIsOffline = errors.New("service is offline")

ErrServiceIsOffline indicates that a health check dependency is offline.

Functions

func AddHealthCheck deprecated

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.

Deprecated: use NewState and State.AddHealthCheck for explicit ownership.

func CheckHealth deprecated

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.

Deprecated: use NewState and State.CheckHealth for explicit ownership.

func ExecuteHealthCheck deprecated

func ExecuteHealthCheck() error

ExecuteHealthCheck runs every registered health check.

Deprecated: use CheckHealth.

func Monitor deprecated

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()

Deprecated: use NewState and State.Monitor for explicit ownership.

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 NewState

func NewState() *State

NewState returns isolated profiler health and probe state.

func (*State) AddHealthCheck

func (s *State) 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 (*State) CheckHealth

func (s *State) CheckHealth() error

CheckHealth runs every registered health check concurrently and returns a joined error if any fail.

func (*State) IsReady

func (s *State) IsReady() bool

IsReady returns the readiness probe flag.

func (*State) IsStarted

func (s *State) IsStarted() bool

IsStarted returns the startup probe flag.

func (*State) Monitor

func (s *State) Monitor(addr string) func()

Monitor starts a standalone HTTP server on addr using this state.

func (*State) Reset

func (s *State) Reset()

Reset clears health checks and probe flags.

func (*State) SetReady

func (s *State) SetReady(ready bool)

SetReady stores the readiness probe flag.

func (*State) SetStarted

func (s *State) SetStarted(started bool)

SetStarted stores the startup probe flag.

Jump to

Keyboard shortcuts

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