skeeph
skeeph

Reputation: 490

Check grpc server availability?

Is there any way to check that grpc-server is up without making actual procedure calls and implementing additional queries (i.e. rpc HealthCheck (Input) returns (Status))?

Upvotes: 7

Views: 15474

Answers (1)

Eric Anderson
Eric Anderson

Reputation: 26464

Most clients should use the channel state API. In Java, for instance, that is available via state = managedChannel.getState(false);. Treating {IDLE, CONNECTING, READY} as "good" is appropriate in many circumstances, but if you are very latency sensitive you can only consider READY as "good" and should pass true to getState().

Note that the API does not actively monitor the service's health; it just informs whether the server is currently known to be running and reachable. If you need to know about the service's precise health, then you need to use the Health service, via RPCs. But this is generally expected to be rare, except by load balancers (and not by clients using load balancers).

Upvotes: 8

Related Questions