mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 16:59:22 +02:00
authorize: grpc health check (#2200)
This commit is contained in:
parent
7d5754ec36
commit
c71f7dca5b
3 changed files with 91 additions and 1 deletions
34
pkg/grpc/health.go
Normal file
34
pkg/grpc/health.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
grpc_health "google.golang.org/grpc/health/grpc_health_v1"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/log"
|
||||
)
|
||||
|
||||
type healthCheckSrv struct {
|
||||
}
|
||||
|
||||
// NewHealthCheckServer returns a basic health checker
|
||||
func NewHealthCheckServer() grpc_health.HealthServer {
|
||||
return &healthCheckSrv{}
|
||||
}
|
||||
|
||||
// Check confirms service is reachable, and assumes any service is operational
|
||||
// an outlier detection should be used to detect runtime malfunction based on consequitive 5xx
|
||||
func (h *healthCheckSrv) Check(ctx context.Context, req *grpc_health.HealthCheckRequest) (*grpc_health.HealthCheckResponse, error) {
|
||||
log.Debug(ctx).Str("service", req.Service).Msg("health check")
|
||||
return &grpc_health.HealthCheckResponse{
|
||||
Status: grpc_health.HealthCheckResponse_SERVING,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Watch is not implemented as is not used by Envoy
|
||||
func (h *healthCheckSrv) Watch(req *grpc_health.HealthCheckRequest, _ grpc_health.Health_WatchServer) error {
|
||||
log.Error(context.Background()).Str("service", req.Service).Msg("health check watch")
|
||||
return status.Errorf(codes.Unimplemented, "method Watch not implemented")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue