How do I use the Ruby gRPC health check library

4/25/2019

I need to implement gRPC health check so I can use my gRPC API in Kubernetes.

I've worked out that I need to put the health checking proto file in my server, and implement it.

It looks like there's a library that already implements it for Ruby, but I can't work out how to use it.

I've got the 'grpc' gem installed and I've tried this:

require 'grpc/health/checker'

# Implement health service.
health_svc = Grpc::Health::Checker.new
health_svc.add_status("plugin", Grpc::Health::V1::HealthCheckResponse::
ServingStatus::SERVING)

And I've tried this:

require 'health_check_services_pb'

class HealthCheckService < Grpc::Health::V1::Health::Service
  def check(req, req_view)
    checker = Grpc::Health::Checker.new
    checker.check(req, req_view)
  end
end

but I keep getting the error:

NameError: uninitialized constant Grpc::Health::Checker

So how do I use the library (other than copy all the library code from GitHub into my server)?

-- Toby 1 Kenobi
grpc
kubernetes-health-check
ruby

1 Answer

8/16/2019

Looks like the correct requires for the protobufs are

require 'grpc/health/v1/health_pb'
require 'grpc/health/v1/health_services_pb'

as found in checker_spec.rb

-- Trevor Creech
Source: StackOverflow