feat(anubis): add /healthz route to metrics server (#843)
* 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>
This commit is contained in:
parent
509a4f3ce8
commit
68b653b099
13 changed files with 372 additions and 248 deletions
25
internal/health.go
Normal file
25
internal/health.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue