Files
vt/utils/healthcheck.go
2026-01-22 17:39:04 +01:00

27 lines
747 B
Go

package utils
// Keep (used in cmd/api/main.go)
// Healthcheck utilities for gRPC services
// using connect-go and grpchealth
import (
"connectrpc.com/grpchealth"
"git.kocoder.xyz/kocoded/vt/fx"
"git.kocoder.xyz/kocoded/vt/gen/project/v1/projectv1connect"
"git.kocoder.xyz/kocoded/vt/gen/todo/v1/todov1connect"
)
func NewHealthchecker() grpchealth.Checker {
checker := grpchealth.NewStaticChecker()
checker.SetStatus(projectv1connect.ProjectServiceName, grpchealth.StatusServing)
checker.SetStatus(todov1connect.TodoServiceName, grpchealth.StatusServing)
return checker
}
func NewHealthCheckV1(healthChecker grpchealth.Checker) fx.Handler {
path, handler := grpchealth.NewHandler(healthChecker)
return fx.NewRoute(path, handler)
}