检查grpc服务器的可用性? [英] Check grpc server availability?

查看:71
本文介绍了检查grpc服务器的可用性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法检查 grpc-server 是否正常,而无需进行实际的过程调用和实现其他查询(即 rpc HealthCheck(输入)返回(状态))?

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))?

推荐答案

大多数客户端应使用 true 传递给 getState().

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().

请注意,API不会主动监视服务的运行状况;它只是告知服务器当前是否已知正在运行并且可以访问.如果您需要了解服务的确切运行状况,则需要通过RPC使用运行状况服务.但这通常很少见,除非负载均衡器(而不是使用负载均衡器的客户端)除外.

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).

这篇关于检查grpc服务器的可用性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆