mirror of
https://github.com/TecharoHQ/anubis.git
synced 2025-08-03 17:59:24 -04:00

* feat(anubis): add /healthz route to metrics server Also add health check test for Docker Compose and update documentation for health checking Anubis with Docker Compose. Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: spelling Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net>
26 lines
577 B
Go
26 lines
577 B
Go
package internal
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc/health"
|
|
healthv1 "google.golang.org/grpc/health/grpc_health_v1"
|
|
)
|
|
|
|
var HealthSrv = health.NewServer()
|
|
|
|
func SetHealth(svc string, status healthv1.HealthCheckResponse_ServingStatus) {
|
|
HealthSrv.SetServingStatus(svc, status)
|
|
}
|
|
|
|
func GetHealth(svc string) (healthv1.HealthCheckResponse_ServingStatus, bool) {
|
|
st, err := HealthSrv.Check(context.Background(), &healthv1.HealthCheckRequest{
|
|
Service: svc,
|
|
})
|
|
if err != nil {
|
|
return healthv1.HealthCheckResponse_UNKNOWN, false
|
|
}
|
|
|
|
return st.GetStatus(), true
|
|
}
|