health

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check func(ctx context.Context) error

Check runs all registered checks and returns status.

type Checker

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

Checker runs health checks.

func New

func New() *Checker

New creates a health checker.

func (*Checker) Add

func (c *Checker) Add(name string, fn Check)

Add registers a check.

func (*Checker) DB

func (c *Checker) DB(db *lucid.DB)

DB adds a database ping check.

func (*Checker) Handler

func (c *Checker) Handler() http.StdHandlerFunc

Handler returns an http.Handler that writes JSON health status. You can mount this as a liveness or readiness endpoint depending on which checks you register on the Checker.

func (*Checker) Redis

func (c *Checker) Redis(rdb *redis.Client)

Redis adds a Redis ping check.

func (*Checker) Run

func (c *Checker) Run(ctx context.Context) Result

Run executes all checks. Returns Result with status "ok" if all pass, "degraded" otherwise.

type Result

type Result struct {
	Status  string            `json:"status"` // "ok" or "degraded"
	Checks  map[string]string `json:"checks,omitempty"`
	Message string            `json:"message,omitempty"`
}

Result holds the health check result.

Jump to

Keyboard shortcuts

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