Merge pull request #22369 from lidizheng/health-default

[Health Checking] Make the empty service default to SERVING state
pull/22380/head
Lidi Zheng 5 years ago committed by GitHub
commit 7be8cef10a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/python/grpcio_health_checking/grpc_health/v1/_async.py
  2. 2
      src/python/grpcio_health_checking/grpc_health/v1/health.py
  3. 1
      src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
  4. 2
      src/python/grpcio_tests/tests_aio/health_check/health_servicer_test.py

@ -30,7 +30,7 @@ class HealthServicer(_health_pb2_grpc.HealthServicer):
_gracefully_shutting_down: bool _gracefully_shutting_down: bool
def __init__(self) -> None: def __init__(self) -> None:
self._server_status = dict() self._server_status = {"": _health_pb2.HealthCheckResponse.SERVING}
self._server_watchers = collections.defaultdict(asyncio.Condition) self._server_watchers = collections.defaultdict(asyncio.Condition)
self._gracefully_shutting_down = False self._gracefully_shutting_down = False

@ -85,7 +85,7 @@ class HealthServicer(_health_pb2_grpc.HealthServicer):
experimental_non_blocking=True, experimental_non_blocking=True,
experimental_thread_pool=None): experimental_thread_pool=None):
self._lock = threading.RLock() self._lock = threading.RLock()
self._server_status = {} self._server_status = {"": _health_pb2.HealthCheckResponse.SERVING}
self._send_response_callbacks = {} self._send_response_callbacks = {}
self.Watch.__func__.experimental_non_blocking = experimental_non_blocking self.Watch.__func__.experimental_non_blocking = experimental_non_blocking
self.Watch.__func__.experimental_thread_pool = experimental_thread_pool self.Watch.__func__.experimental_thread_pool = experimental_thread_pool

@ -50,7 +50,6 @@ class BaseWatchTests(object):
self._servicer = health.HealthServicer( self._servicer = health.HealthServicer(
experimental_non_blocking=non_blocking, experimental_non_blocking=non_blocking,
experimental_thread_pool=thread_pool) experimental_thread_pool=thread_pool)
self._servicer.set('', health_pb2.HealthCheckResponse.SERVING)
self._servicer.set(_SERVING_SERVICE, self._servicer.set(_SERVING_SERVICE,
health_pb2.HealthCheckResponse.SERVING) health_pb2.HealthCheckResponse.SERVING)
self._servicer.set(_UNKNOWN_SERVICE, self._servicer.set(_UNKNOWN_SERVICE,

@ -47,8 +47,6 @@ class HealthServicerTest(AioTestBase):
async def setUp(self): async def setUp(self):
self._servicer = health.aio.HealthServicer() self._servicer = health.aio.HealthServicer()
await self._servicer.set(health.OVERALL_HEALTH,
health_pb2.HealthCheckResponse.SERVING)
await self._servicer.set(_SERVING_SERVICE, await self._servicer.set(_SERVING_SERVICE,
health_pb2.HealthCheckResponse.SERVING) health_pb2.HealthCheckResponse.SERVING)
await self._servicer.set(_UNKNOWN_SERVICE, await self._servicer.set(_UNKNOWN_SERVICE,

Loading…
Cancel
Save