health_check

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 8 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

View Source
const (
	// EndpointFieldName is the command-line flag for health check endpoint path.
	EndpointFieldName = "server.http.routes.health_check"

	// EndpointDefault is the default path for health checks.
	EndpointDefault = "/health-check"
)

Variables

View Source
var Component = &component.Component{
	Dependencies: component.Components{
		chi.Component,
	},
	Init: component.StepFunc(func(container container.Container) error {
		return container.Provide(NewConfig)
	}),
	BindFlags: component.BindFlags(func(flagSet flag.FlagSet, container container.Container) error {
		return container.Invoke(func(config *Config) {
			flagSet.StringVar(&config.Endpoint, EndpointFieldName, EndpointDefault, "path for liveness test endpoint")
		})
	}),
	Configuration: component.StepFunc(func(container container.Container) error {
		return container.Invoke(Configuration)
	}),
	PreExecute: component.StepFunc(func(container container.Container) error {
		return container.Invoke(func(config *Config, r http.Router, logger logger.Logger) {
			logger.Infof("[chi.router] add health endpoint - '%s'", config.Endpoint)
			r.Use(http.MiddlewareFunc(middleware.Heartbeat(config.Endpoint)))
		})
	}),
}

Component adds a health check endpoint to the HTTP router using chi's heartbeat middleware. It depends on chi.Component for the router.

Usage:

compogo.WithComponents(
    http.Component,
    chi.Component,
    health_check.Component,
)

Health check responds with 200 OK at: /health-check (configurable)

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoint string
}

Config holds the health check endpoint configuration.

func Configuration

func Configuration(config *Config, configurator configurator.Configurator) *Config

Configuration applies configuration values to the Config struct. It reads from the provided configurator and sets defaults if values are not present.

func NewConfig

func NewConfig() *Config

NewConfig creates a new Config instance with default values.

Jump to

Keyboard shortcuts

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