[Ruby] How to use Grpc::Health::Checker?

26 views
Skip to first unread message

Michel Vocks

unread,
Jan 14, 2019, 4:13:43 PM1/14/19
to grpc.io
Hello folks,

I would like to use the ruby Health-Check implementation. I was able to find the following documentation: https://www.rubydoc.info/gems/grpc/Grpc/Health/Checker
Anyway, if I want to implement that service I get the error "Error occured: uninitialized constant Grpc".
I'm using the following code snippet:

 # Implement health service.
 health_svc
= Grpc::Health::Checker.new
 health_svc
.add_status("myservice", GRPC::Core::StatusCodes::SERVING)

I'm also unsure how to attach that service to my gRPC server?
Is there somewhere an official example available?

Any help is much appreciated! :-)

Michel Vocks

unread,
Jan 16, 2019, 1:17:20 PM1/16/19
to grpc.io
I was able to solve it with the following code snippet:

require 'grpc/health/checker'


# Implement health service.
health_svc
= Grpc::Health::Checker.new

health_svc
.add_status("plugin", Grpc::Health::V1::HealthCheckResponse::ServingStatus::SERVING)

# Register gRPC server and handle.
host
= '127.0.0.1'
s
= GRPC::RpcServer.new
port
= s.add_http2_port(host+':0', :this_port_is_insecure)
s
.handle(health_svc)



Reply all
Reply to author
Forward
0 new messages