Skip to content

Health Checks

pkg/health exposes HTTP health check endpoints using hellofresh/health-go.

lakta.NewRuntime(
config.NewModule(
config.WithConfigDirs(".", "./config"),
config.WithArgs(os.Args[1:]),
),
slog.NewModule(),
fiber.NewModule(), // health endpoints are registered on the HTTP server
health.NewModule(),
myapp.NewModule(),
)
PathDescription
GET /health/liveLiveness — is the process alive?
GET /health/readyReadiness — can the service handle requests?
func (m *MyModule) Init(ctx context.Context) error {
h := do.MustInvoke[*health.Health](lakta.GetInjector(ctx))
h.Register(health.Config{
Name: "database",
Check: func(ctx context.Context) error {
return m.pool.Ping(ctx)
},
})
return nil
}

Config path: modules.health.health.<name>

component_name string

componentName defines the name of the component

env LAKTA_MODULES_HEALTH_HEALTH_<NAME>_COMPONENT_NAME
component_version string

componentVersion represents the version of the component

env LAKTA_MODULES_HEALTH_HEALTH_<NAME>_COMPONENT_VERSION

These options can only be set in Go code via With*() functions, not via config files or environment variables.

OptionTypeDescription
WithCheck(...)[]health.Configadds a health check to be registered on initialization (code-only)