Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to revive old health service addition #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions grpc_health-stubs/v1/health_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import typing

from google.protobuf.descriptor import (
Descriptor,
EnumDescriptor,
FileDescriptor,
)

from google.protobuf.internal.enum_type_wrapper import (
_EnumTypeWrapper,
)

from google.protobuf.message import (
Message,
)

from typing_extensions import (
Literal,
TypeAlias,
)


DESCRIPTOR: FileDescriptor

class HealthCheckRequest(Message):
DESCRIPTOR: Descriptor
SERVICE_FIELD_NUMBER: int
service: typing.Text
def __init__(self,
*,
service: typing.Text = ...,
) -> None: ...
def ClearField(self, field_name: Literal["service",b"service"]) -> None: ...

class HealthCheckResponse(Message):
DESCRIPTOR: Descriptor
class _ServingStatus:
ValueType = typing.NewType('ValueType', int)
V: TypeAlias = ValueType

class _ServingStatusEnumTypeWrapper(_EnumTypeWrapper[HealthCheckResponse._ServingStatus.ValueType], type):
DESCRIPTOR: EnumDescriptor
UNKNOWN: HealthCheckResponse._ServingStatus.ValueType # 0
SERVING: HealthCheckResponse._ServingStatus.ValueType # 1
NOT_SERVING: HealthCheckResponse._ServingStatus.ValueType # 2
SERVICE_UNKNOWN: HealthCheckResponse._ServingStatus.ValueType # 3
"""Used only by the Watch method."""

class ServingStatus(_ServingStatus, metaclass=_ServingStatusEnumTypeWrapper):
pass

UNKNOWN: HealthCheckResponse.ServingStatus.ValueType # 0
SERVING: HealthCheckResponse.ServingStatus.ValueType # 1
NOT_SERVING: HealthCheckResponse.ServingStatus.ValueType # 2
SERVICE_UNKNOWN: HealthCheckResponse.ServingStatus.ValueType # 3
"""Used only by the Watch method."""


STATUS_FIELD_NUMBER: int
status: HealthCheckResponse.ServingStatus.ValueType
def __init__(self,
*,
status: HealthCheckResponse.ServingStatus.ValueType = ...,
) -> None: ...
def ClearField(self, field_name: Literal["status",b"status"]) -> None: ...

42 changes: 42 additions & 0 deletions grpc_health-stubs/v1/health_pb2_grpc.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from grpc import (
Channel,
Server,
ServicerContext,
UnaryStreamMultiCallable,
UnaryUnaryMultiCallable,
)

from .health_pb2 import (
HealthCheckRequest,
HealthCheckResponse,
)

from typing import (
Iterator,
)


class HealthStub:
def __init__(self, channel: Channel) -> None: ...
Check: UnaryUnaryMultiCallable[
HealthCheckRequest,
HealthCheckResponse]

Watch: UnaryStreamMultiCallable[
HealthCheckRequest,
HealthCheckResponse]


class HealthServicer:
def Check(self,
request: HealthCheckRequest,
context: ServicerContext,
) -> HealthCheckResponse: ...

def Watch(self,
request: HealthCheckRequest,
context: ServicerContext,
) -> Iterator[HealthCheckResponse]: ...


def add_HealthServicer_to_server(servicer: HealthServicer, server: Server) -> None: ...
Empty file added grpc_health-stubs/v1/py.typed
Empty file.
11 changes: 11 additions & 0 deletions typesafety/test_grpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,14 @@
server = typing.cast(aio.Server, None)
enable_server_reflection(["foo"], server, None)

- case: issue_30_healthservicer_set
main: |
import typing
import grpc
from grpc_health.v1 import health, health_pb2, health_pb2_grpc
server = typing.cast(grpc.Server, None)
health_servicer = typing.cast(health.HealthServicer, None)
health_pb2_grpc.add_HealthServicer_to_server(health_servicer, server)
service = "service"
health_servicer.set(service, health_pb2.HealthCheckResponse.SERVING)