health_check

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const EndpointFieldName = "server.http.routes.health_check"

EndpointFieldName имя поля в конфигурации

Variables

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

			r.Use(httpServer.MiddlewareFunc(middleware.Heartbeat(config.Endpoint)))
		})
	}),
}

Component — компонент health-check эндпоинта для chi-роутера. Добавляет эндпоинт для проверки живости сервиса (liveness probe).

View Source
var EndpointDefault = "/health-check"

EndpointDefault путь по умолчанию

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoint string
}

Config содержит конфигурацию health-check эндпоинта.

func Configuration

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

Configuration загружает конфигурацию из Configurator.

func NewConfig

func NewConfig() *Config

NewConfig создаёт новую конфигурацию.

Jump to

Keyboard shortcuts

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