|
|
|
|
@@ -4,7 +4,7 @@ import threading
|
|
|
|
|
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
|
|
|
|
|
from concurrent import futures
|
|
|
|
|
from types import ModuleType, TracebackType
|
|
|
|
|
from typing import Any, Generic, NoReturn, Protocol, TypeVar, type_check_only
|
|
|
|
|
from typing import Generic, NoReturn, Protocol, TypeVar, type_check_only
|
|
|
|
|
from typing_extensions import Self, TypeAlias
|
|
|
|
|
|
|
|
|
|
from . import aio as aio
|
|
|
|
|
@@ -16,9 +16,9 @@ _T = TypeVar("_T")
|
|
|
|
|
# XXX: Early attempts to tame this used literals for all the keys (gRPC is
|
|
|
|
|
# a bit segfaulty and doesn't adequately validate the option keys), but that
|
|
|
|
|
# didn't quite work out. Maybe it's something we can come back to
|
|
|
|
|
_OptionKeyValue: TypeAlias = tuple[str, Any]
|
|
|
|
|
_OptionKeyValue: TypeAlias = tuple[str, object]
|
|
|
|
|
Options: TypeAlias = Sequence[_OptionKeyValue]
|
|
|
|
|
_Options: TypeAlias = Options
|
|
|
|
|
Options: TypeAlias = Options
|
|
|
|
|
|
|
|
|
|
class Compression(enum.IntEnum):
|
|
|
|
|
NoCompression = 0
|
|
|
|
|
@@ -71,9 +71,9 @@ class Future(abc.ABC, Generic[_TFutureValue]):
|
|
|
|
|
|
|
|
|
|
# Create Client:
|
|
|
|
|
|
|
|
|
|
def insecure_channel(target: str, options: _Options | None = None, compression: Compression | None = None) -> Channel: ...
|
|
|
|
|
def insecure_channel(target: str, options: Options | None = None, compression: Compression | None = None) -> Channel: ...
|
|
|
|
|
def secure_channel(
|
|
|
|
|
target: str, credentials: ChannelCredentials, options: _Options | None = None, compression: Compression | None = None
|
|
|
|
|
target: str, credentials: ChannelCredentials, options: Options | None = None, compression: Compression | None = None
|
|
|
|
|
) -> Channel: ...
|
|
|
|
|
|
|
|
|
|
_Interceptor: TypeAlias = (
|
|
|
|
|
@@ -108,7 +108,7 @@ def server(
|
|
|
|
|
thread_pool: futures.ThreadPoolExecutor,
|
|
|
|
|
handlers: list[GenericRpcHandler] | None = None,
|
|
|
|
|
interceptors: list[ServerInterceptor] | None = None,
|
|
|
|
|
options: _Options | None = None,
|
|
|
|
|
options: Options | None = None,
|
|
|
|
|
maximum_concurrent_rpcs: int | None = None,
|
|
|
|
|
compression: Compression | None = None,
|
|
|
|
|
xds: bool = False,
|
|
|
|
|
@@ -147,7 +147,7 @@ def xds_server_credentials(fallback_credentials: ServerCredentials) -> ServerCre
|
|
|
|
|
#
|
|
|
|
|
@type_check_only
|
|
|
|
|
class _Behaviour(Protocol):
|
|
|
|
|
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
|
|
|
|
def __call__(self, *args: object, **kwargs: object) -> object: ...
|
|
|
|
|
|
|
|
|
|
def unary_unary_rpc_method_handler(
|
|
|
|
|
behavior: _Behaviour,
|
|
|
|
|
@@ -170,7 +170,7 @@ def stream_stream_rpc_method_handler(
|
|
|
|
|
response_serializer: _Serializer[_TResponse] | None = None,
|
|
|
|
|
) -> RpcMethodHandler[_TRequest, _TResponse]: ...
|
|
|
|
|
def method_handlers_generic_handler(
|
|
|
|
|
service: str, method_handlers: dict[str, RpcMethodHandler[Any, Any]]
|
|
|
|
|
service: str, method_handlers: dict[str, RpcMethodHandler[object, object]]
|
|
|
|
|
) -> GenericRpcHandler: ...
|
|
|
|
|
|
|
|
|
|
# Channel Ready Future:
|
|
|
|
|
@@ -284,20 +284,13 @@ class Server(abc.ABC):
|
|
|
|
|
|
|
|
|
|
# Authentication & Authorization Objects:
|
|
|
|
|
|
|
|
|
|
# Credentials are opaque to user space; keep them typed without Any.
|
|
|
|
|
class _Credentials(Protocol):
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
class _CertificateConfiguration(Protocol):
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
# This class has no supported interface
|
|
|
|
|
class ChannelCredentials:
|
|
|
|
|
def __init__(self, credentials: _Credentials) -> None: ...
|
|
|
|
|
def __init__(self, credentials: object) -> None: ...
|
|
|
|
|
|
|
|
|
|
# This class has no supported interface
|
|
|
|
|
class CallCredentials:
|
|
|
|
|
def __init__(self, credentials: _Credentials) -> None: ...
|
|
|
|
|
def __init__(self, credentials: object) -> None: ...
|
|
|
|
|
|
|
|
|
|
class AuthMetadataContext(abc.ABC):
|
|
|
|
|
service_url: str
|
|
|
|
|
@@ -311,11 +304,11 @@ class AuthMetadataPlugin(abc.ABC):
|
|
|
|
|
|
|
|
|
|
# This class has no supported interface
|
|
|
|
|
class ServerCredentials:
|
|
|
|
|
def __init__(self, credentials: _Credentials) -> None: ...
|
|
|
|
|
def __init__(self, credentials: object) -> None: ...
|
|
|
|
|
|
|
|
|
|
# This class has no supported interface
|
|
|
|
|
class ServerCertificateConfiguration:
|
|
|
|
|
def __init__(self, certificate_configuration: _CertificateConfiguration) -> None: ...
|
|
|
|
|
def __init__(self, certificate_configuration: object) -> None: ...
|
|
|
|
|
|
|
|
|
|
# gRPC Exceptions:
|
|
|
|
|
|
|
|
|
|
@@ -498,7 +491,7 @@ class HandlerCallDetails(abc.ABC):
|
|
|
|
|
class GenericRpcHandler(abc.ABC):
|
|
|
|
|
# The return type depends on the handler call details.
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
|
def service(self, handler_call_details: HandlerCallDetails) -> RpcMethodHandler[Any, Any] | None: ...
|
|
|
|
|
def service(self, handler_call_details: HandlerCallDetails) -> RpcMethodHandler[object, object] | None: ...
|
|
|
|
|
|
|
|
|
|
class ServiceRpcHandler(GenericRpcHandler, metaclass=abc.ABCMeta):
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
|
@@ -615,4 +608,4 @@ class StreamStreamMultiCallable(abc.ABC, Generic[_TRequest, _TResponse]):
|
|
|
|
|
|
|
|
|
|
def protos(protobuf_path: str) -> ModuleType: ...
|
|
|
|
|
def services(protobuf_path: str) -> ModuleType: ...
|
|
|
|
|
def protos_and_services(protobuf_path: str) -> tuple[ModuleType, ModuleType]: ...
|
|
|
|
|
def protos_and_services(protobuf_path: str) -> tuple[ModuleType, ModuleType]: ...
|