health

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package health exposes a small HTTP server with /health (liveness) and /ready (readiness) endpoints so that operators and orchestrators can monitor a running pgstream process.

Index

Constants

View Source
const (
	DefaultAddress = "localhost:9910"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled bool
	Address string
}

Config controls how the health server is exposed.

type Option

type Option func(*Server)

func WithLogger

func WithLogger(l loglib.Logger) Option

func WithReadinessCheck

func WithReadinessCheck(fn func(ctx context.Context) error) Option

WithReadinessCheck registers a function the /ready handler will invoke. The function is given a context with a short timeout; returning a non-nil error causes /ready to respond with 503. If no check is registered, /ready behaves like /health.

func WithVersion

func WithVersion(v string) Option

type Server

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

Server serves /health and /ready over HTTP.

func NewServer

func NewServer(cfg Config, opts ...Option) *Server

NewServer builds a health server from the given config. The server is not started until Start() is called.

func (*Server) Listen

func (s *Server) Listen() error

Listen binds the configured address synchronously and prepares the HTTP server. After it returns successfully, Serve must be called (typically from a goroutine) to start accepting requests. Splitting bind from serve lets callers surface bind errors synchronously and ensures Shutdown always observes an initialised server.

func (*Server) Serve

func (s *Server) Serve() error

Serve starts serving requests on the listener bound by Listen. It blocks until Shutdown is called. ErrServerClosed is treated as a clean exit.

func (*Server) Shutdown

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

Shutdown stops the underlying HTTP server gracefully. Safe to call when the server was never started.

Jump to

Keyboard shortcuts

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