Nexus/pkg/internal/grpc/health.go

28 lines
598 B
Go
Raw Permalink Normal View History

2024-10-19 14:36:33 +00:00
package grpc
import (
"context"
"time"
health "google.golang.org/grpc/health/grpc_health_v1"
)
2024-10-20 11:04:41 +00:00
func (v *Server) Check(ctx context.Context, request *health.HealthCheckRequest) (*health.HealthCheckResponse, error) {
2024-10-19 14:36:33 +00:00
return &health.HealthCheckResponse{
Status: health.HealthCheckResponse_SERVING,
}, nil
}
2024-10-20 11:04:41 +00:00
func (v *Server) Watch(request *health.HealthCheckRequest, server health.Health_WatchServer) error {
2024-10-19 14:36:33 +00:00
for {
if server.Send(&health.HealthCheckResponse{
Status: health.HealthCheckResponse_SERVING,
}) != nil {
break
}
time.Sleep(1000 * time.Millisecond)
}
return nil
}