pomerium/pkg/grpc/health.go
Caleb Doxsey d1559eaa86
upgrade google.golang.org/grpc/health/grpc_health_v1 (#5605)
## Summary
Upgrade `google.golang.org/grpc/health/grpc_health_v1` which has a new
`List` method, so use the `UnimplementedHealthServer`.

## Related issues
- https://github.com/pomerium/ingress-controller/pull/1152

## User Explanation

<!-- How would you explain this change to the user? If this
change doesn't create any user-facing changes, you can leave
this blank. If filled out, add the `docs` label -->

## Checklist

- [ ] reference any related issues
- [ ] updated unit tests
- [ ] add appropriate label (`enhancement`, `bug`, `breaking`,
`dependencies`, `ci`)
- [x] ready for review
2025-05-02 14:32:04 -06:00

27 lines
840 B
Go

package grpc
import (
"context"
"google.golang.org/grpc/health/grpc_health_v1"
"github.com/pomerium/pomerium/internal/log"
)
type healthCheckSrv struct {
grpc_health_v1.UnimplementedHealthServer
}
// NewHealthCheckServer returns a basic health checker
func NewHealthCheckServer() grpc_health_v1.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_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) {
log.Ctx(ctx).Debug().Str("service", req.Service).Msg("health check")
return &grpc_health_v1.HealthCheckResponse{
Status: grpc_health_v1.HealthCheckResponse_SERVING,
}, nil
}