Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
Signed-off-by: Yevgen Polyak <yevgen.polyak@gmail.com>
  • Loading branch information
evhen14 committed Jun 25, 2024
1 parent 4d80ca0 commit a75859b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dapr.proto import appcallback_service_v1
from dapr.proto.runtime.v1.appcallback_pb2 import HealthCheckResponse

HealthCheckCallable = Callable[[], None]
HealthCheckCallable = Optional[Callable[[], None]]


class _HealthCheckServicer(appcallback_service_v1.AppCallbackHealthCheckServicer):
Expand All @@ -13,19 +13,19 @@ class _HealthCheckServicer(appcallback_service_v1.AppCallbackHealthCheckServicer
:class:`App` provides useful decorators to register method, topic, input bindings.
"""

def __init__(self):
self._health_check_cb: Optional[HealthCheckCallable] = None

def register_health_check(self, cb: HealthCheckCallable) -> None:
if not cb:
raise ValueError('health check callback must be defined')
self._health_check_cb = cb

def __init__(self):
self._health_check_cb: Optional[HealthCheckCallable] = None

def HealthCheck(self, request, context):
"""Health check."""

if not self._health_check_cb:
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_code(grpc.StatusCode.UNIMPLEMENTED) # type: ignore
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
self._health_check_cb()
Expand Down
2 changes: 1 addition & 1 deletion ext/dapr-ext-grpc/dapr/ext/grpc/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from dapr.conf import settings
from dapr.ext.grpc._servicer import _CallbackServicer, Rule # type: ignore
from dapr.ext.grpc._health_servicer import _HealthCheckServicer
from dapr.ext.grpc._health_servicer import _HealthCheckServicer # type: ignore
from dapr.proto import appcallback_service_v1


Expand Down

0 comments on commit a75859b

Please sign in to comment.