mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-12 05:33:11 +01:00
Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com> Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> Co-authored-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
29 lines
869 B
Go
29 lines
869 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/cloudnative-pg/machinery/pkg/log"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/health/grpc_health_v1"
|
|
)
|
|
|
|
// AddHealthCheck adds a health check service to the gRPC server with the tag 'plugin-barman-cloud'
|
|
func AddHealthCheck(server *grpc.Server) {
|
|
grpc_health_v1.RegisterHealthServer(server, &healthServer{}) // replaces default registration
|
|
}
|
|
|
|
type healthServer struct {
|
|
grpc_health_v1.UnimplementedHealthServer
|
|
}
|
|
|
|
// Check is the response handle for the healthcheck request
|
|
func (h healthServer) Check(
|
|
ctx context.Context,
|
|
_ *grpc_health_v1.HealthCheckRequest,
|
|
) (*grpc_health_v1.HealthCheckResponse, error) {
|
|
contextLogger := log.FromContext(ctx)
|
|
contextLogger.Trace("serving health check response")
|
|
return &grpc_health_v1.HealthCheckResponse{Status: grpc_health_v1.HealthCheckResponse_SERVING}, nil
|
|
}
|