diff options
author | thegeorg <thegeorg@yandex-team.com> | 2022-11-02 21:28:47 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2022-11-02 21:28:47 +0300 |
commit | 2bdc13c7a8dc2203aa7d5f8db4328307cb295049 (patch) | |
tree | 6df9a30586a2ddc28d87abc63f5f097aed53e591 | |
parent | b7ba2c1cd98b314e1a2685737d711b8160ce6ed4 (diff) | |
download | ydb-2bdc13c7a8dc2203aa7d5f8db4328307cb295049.tar.gz |
Proxy grpc python runtime from contrib/python/grpcio
* [grpcio](https://pypi.org/project/grpcio/) is the official package for using grpc from python
* grpcio itself remains in `contrib/libs/grpc/src/python/grpcio` while `contrib/python/grpcio` is a public proxy that should be used by everyone
* `grpcio-status` and `grpcio-reflection` were put under yamaker pypi
* certain unused parts of grpc/src/python have been removed
Make precommit hook happy:
24 files changed, 0 insertions, 1059 deletions
diff --git a/contrib/libs/grpc/src/python/grpcio_admin/README.rst b/contrib/libs/grpc/src/python/grpcio_admin/README.rst deleted file mode 100644 index d9959840eb..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_admin/README.rst +++ /dev/null @@ -1,23 +0,0 @@ -gRPC Python Admin Interface Package -=================================== - -Debugging gRPC library can be a complex task. There are many configurations and -internal states, which will affect the behavior of the library. This Python -package will be the collection of admin services that are exposing debug -information. Currently, it includes: - -* Channel tracing metrics (grpcio-channelz) -* Client Status Discovery Service (grpcio-csds) - -Here is a snippet to create an admin server on "localhost:50051": - - server = grpc.server(ThreadPoolExecutor()) - port = server.add_insecure_port('localhost:50051') - grpc_admin.add_admin_servicers(self._server) - server.start() - -Welcome to explore the admin services with CLI tool "grpcdebug": -https://github.com/grpc-ecosystem/grpcdebug. - -For any issues or suggestions, please send to -https://github.com/grpc/grpc/issues. diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/README.rst b/contrib/libs/grpc/src/python/grpcio_channelz/README.rst deleted file mode 100644 index 526b34ac83..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/README.rst +++ /dev/null @@ -1,13 +0,0 @@ -gRPC Python Channelz package -============================== - -Channelz is a live debug tool in gRPC Python. - -Supported Python Versions -------------------------- -Python >= 3.6 - -Dependencies ------------- - -Depends on the `grpcio` package, available from PyPI via `pip install grpcio`. diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/__init__.py b/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/__init__.py deleted file mode 100644 index 38fdfc9c5c..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2018 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/__init__.py b/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/__init__.py deleted file mode 100644 index 38fdfc9c5c..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2018 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/_async.py b/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/_async.py deleted file mode 100644 index 463f5e14dc..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/_async.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2020 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""AsyncIO version of Channelz servicer.""" - -from grpc.experimental import aio -from grpc_channelz.v1._servicer import \ - ChannelzServicer as _SyncChannelzServicer -import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 -import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc - - -class ChannelzServicer(_channelz_pb2_grpc.ChannelzServicer): - """AsyncIO servicer for handling RPCs for service statuses.""" - - @staticmethod - async def GetTopChannels( - request: _channelz_pb2.GetTopChannelsRequest, - context: aio.ServicerContext - ) -> _channelz_pb2.GetTopChannelsResponse: - return _SyncChannelzServicer.GetTopChannels(request, context) - - @staticmethod - async def GetServers( - request: _channelz_pb2.GetServersRequest, - context: aio.ServicerContext) -> _channelz_pb2.GetServersResponse: - return _SyncChannelzServicer.GetServers(request, context) - - @staticmethod - async def GetServer( - request: _channelz_pb2.GetServerRequest, - context: aio.ServicerContext) -> _channelz_pb2.GetServerResponse: - return _SyncChannelzServicer.GetServer(request, context) - - @staticmethod - async def GetServerSockets( - request: _channelz_pb2.GetServerSocketsRequest, - context: aio.ServicerContext - ) -> _channelz_pb2.GetServerSocketsResponse: - return _SyncChannelzServicer.GetServerSockets(request, context) - - @staticmethod - async def GetChannel( - request: _channelz_pb2.GetChannelRequest, - context: aio.ServicerContext) -> _channelz_pb2.GetChannelResponse: - return _SyncChannelzServicer.GetChannel(request, context) - - @staticmethod - async def GetSubchannel( - request: _channelz_pb2.GetSubchannelRequest, - context: aio.ServicerContext - ) -> _channelz_pb2.GetSubchannelResponse: - return _SyncChannelzServicer.GetSubchannel(request, context) - - @staticmethod - async def GetSocket( - request: _channelz_pb2.GetSocketRequest, - context: aio.ServicerContext) -> _channelz_pb2.GetSocketResponse: - return _SyncChannelzServicer.GetSocket(request, context) diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/_servicer.py b/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/_servicer.py deleted file mode 100644 index 2d44976ec1..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/_servicer.py +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright 2020 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Channelz debug service implementation in gRPC Python.""" - -from google.protobuf import json_format -import grpc -from grpc._cython import cygrpc -import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 -import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc - - -class ChannelzServicer(_channelz_pb2_grpc.ChannelzServicer): - """Servicer handling RPCs for service statuses.""" - - @staticmethod - def GetTopChannels(request, context): - try: - return json_format.Parse( - cygrpc.channelz_get_top_channels(request.start_channel_id), - _channelz_pb2.GetTopChannelsResponse(), - ) - except (ValueError, json_format.ParseError) as e: - context.set_code(grpc.StatusCode.INTERNAL) - context.set_details(str(e)) - - @staticmethod - def GetServers(request, context): - try: - return json_format.Parse( - cygrpc.channelz_get_servers(request.start_server_id), - _channelz_pb2.GetServersResponse(), - ) - except (ValueError, json_format.ParseError) as e: - context.set_code(grpc.StatusCode.INTERNAL) - context.set_details(str(e)) - - @staticmethod - def GetServer(request, context): - try: - return json_format.Parse( - cygrpc.channelz_get_server(request.server_id), - _channelz_pb2.GetServerResponse(), - ) - except ValueError as e: - context.set_code(grpc.StatusCode.NOT_FOUND) - context.set_details(str(e)) - except json_format.ParseError as e: - context.set_code(grpc.StatusCode.INTERNAL) - context.set_details(str(e)) - - @staticmethod - def GetServerSockets(request, context): - try: - return json_format.Parse( - cygrpc.channelz_get_server_sockets(request.server_id, - request.start_socket_id, - request.max_results), - _channelz_pb2.GetServerSocketsResponse(), - ) - except ValueError as e: - context.set_code(grpc.StatusCode.NOT_FOUND) - context.set_details(str(e)) - except json_format.ParseError as e: - context.set_code(grpc.StatusCode.INTERNAL) - context.set_details(str(e)) - - @staticmethod - def GetChannel(request, context): - try: - return json_format.Parse( - cygrpc.channelz_get_channel(request.channel_id), - _channelz_pb2.GetChannelResponse(), - ) - except ValueError as e: - context.set_code(grpc.StatusCode.NOT_FOUND) - context.set_details(str(e)) - except json_format.ParseError as e: - context.set_code(grpc.StatusCode.INTERNAL) - context.set_details(str(e)) - - @staticmethod - def GetSubchannel(request, context): - try: - return json_format.Parse( - cygrpc.channelz_get_subchannel(request.subchannel_id), - _channelz_pb2.GetSubchannelResponse(), - ) - except ValueError as e: - context.set_code(grpc.StatusCode.NOT_FOUND) - context.set_details(str(e)) - except json_format.ParseError as e: - context.set_code(grpc.StatusCode.INTERNAL) - context.set_details(str(e)) - - @staticmethod - def GetSocket(request, context): - try: - return json_format.Parse( - cygrpc.channelz_get_socket(request.socket_id), - _channelz_pb2.GetSocketResponse(), - ) - except ValueError as e: - context.set_code(grpc.StatusCode.NOT_FOUND) - context.set_details(str(e)) - except json_format.ParseError as e: - context.set_code(grpc.StatusCode.INTERNAL) - context.set_details(str(e)) diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py b/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py deleted file mode 100644 index 605150b79a..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright 2018 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Channelz debug service implementation in gRPC Python.""" - -import sys - -import grpc -from grpc_channelz.v1._servicer import ChannelzServicer -import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc - -_add_channelz_servicer_doc = """Add Channelz servicer to a server. - -Channelz servicer is in charge of -pulling information from C-Core for entire process. It will allow the -server to response to Channelz queries. - -The Channelz statistic is enabled by default inside C-Core. Whether the -statistic is enabled or not is isolated from adding Channelz servicer. -That means you can query Channelz info with a Channelz-disabled channel, -and you can add Channelz servicer to a Channelz-disabled server. - -The Channelz statistic can be enabled or disabled by channel option -'grpc.enable_channelz'. Set to 1 to enable, set to 0 to disable. - -This is an EXPERIMENTAL API. - -Args: - server: A gRPC server to which Channelz service will be added. -""" - -if sys.version_info[0] >= 3 and sys.version_info[1] >= 6: - from grpc_channelz.v1 import _async as aio - - def add_channelz_servicer(server): - - if isinstance(server, grpc.experimental.aio.Server): - _channelz_pb2_grpc.add_ChannelzServicer_to_server( - aio.ChannelzServicer(), server) - else: - _channelz_pb2_grpc.add_ChannelzServicer_to_server( - ChannelzServicer(), server) - - add_channelz_servicer.__doc__ = _add_channelz_servicer_doc - - __all__ = [ - "aio", - "add_channelz_servicer", - "ChannelzServicer", - ] - -else: - - def add_channelz_servicer(server): - _channelz_pb2_grpc.add_ChannelzServicer_to_server( - ChannelzServicer(), server) - - add_channelz_servicer.__doc__ = _add_channelz_servicer_doc - - __all__ = [ - "add_channelz_servicer", - "ChannelzServicer", - ] diff --git a/contrib/libs/grpc/src/python/grpcio_csds/README.rst b/contrib/libs/grpc/src/python/grpcio_csds/README.rst deleted file mode 100644 index f8803f253d..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_csds/README.rst +++ /dev/null @@ -1,10 +0,0 @@ -gRPC Python Client Status Discovery Service package -=================================================== - -CSDS is part of the Envoy xDS protocol: -https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/status/v3/csds.proto. -It allows the gRPC application to programmatically expose the received traffic -configuration (xDS resources). Welcome to explore with CLI tool "grpcdebug": -https://github.com/grpc-ecosystem/grpcdebug. - -For any issues or suggestions, please send to https://github.com/grpc/grpc/issues. diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/README.rst b/contrib/libs/grpc/src/python/grpcio_health_checking/README.rst deleted file mode 100644 index bb4ff867c4..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/README.rst +++ /dev/null @@ -1,13 +0,0 @@ -gRPC Python Health Checking -=========================== - -Reference package for GRPC Python health checking. - -Supported Python Versions -------------------------- -Python >= 3.6 - -Dependencies ------------- - -Depends on the `grpcio` package, available from PyPI via `pip install grpcio`. diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/__init__.py b/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/__init__.py deleted file mode 100644 index 5fb4f3c3cf..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/__init__.py b/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/__init__.py deleted file mode 100644 index 5fb4f3c3cf..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/health.py b/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/health.py deleted file mode 100644 index e5f0e03213..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/health.py +++ /dev/null @@ -1,172 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Reference implementation for health checking in gRPC Python.""" - -import collections -import sys -import threading - -import grpc -from grpc_health.v1 import health_pb2 as _health_pb2 -from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc - -if sys.version_info[0] >= 3 and sys.version_info[1] >= 6: - # Exposes AsyncHealthServicer as public API. - from . import _async as aio # pylint: disable=unused-import - -# The service name of the health checking servicer. -SERVICE_NAME = _health_pb2.DESCRIPTOR.services_by_name['Health'].full_name -# The entry of overall health for the entire server. -OVERALL_HEALTH = '' - - -class _Watcher(): - - def __init__(self): - self._condition = threading.Condition() - self._responses = collections.deque() - self._open = True - - def __iter__(self): - return self - - def _next(self): - with self._condition: - while not self._responses and self._open: - self._condition.wait() - if self._responses: - return self._responses.popleft() - else: - raise StopIteration() - - def next(self): - return self._next() - - def __next__(self): - return self._next() - - def add(self, response): - with self._condition: - self._responses.append(response) - self._condition.notify() - - def close(self): - with self._condition: - self._open = False - self._condition.notify() - - -def _watcher_to_send_response_callback_adapter(watcher): - - def send_response_callback(response): - if response is None: - watcher.close() - else: - watcher.add(response) - - return send_response_callback - - -class HealthServicer(_health_pb2_grpc.HealthServicer): - """Servicer handling RPCs for service statuses.""" - - def __init__(self, - experimental_non_blocking=True, - experimental_thread_pool=None): - self._lock = threading.RLock() - self._server_status = {"": _health_pb2.HealthCheckResponse.SERVING} - self._send_response_callbacks = {} - self.Watch.__func__.experimental_non_blocking = experimental_non_blocking - self.Watch.__func__.experimental_thread_pool = experimental_thread_pool - self._gracefully_shutting_down = False - - def _on_close_callback(self, send_response_callback, service): - - def callback(): - with self._lock: - self._send_response_callbacks[service].remove( - send_response_callback) - send_response_callback(None) - - return callback - - def Check(self, request, context): - with self._lock: - status = self._server_status.get(request.service) - if status is None: - context.set_code(grpc.StatusCode.NOT_FOUND) - return _health_pb2.HealthCheckResponse() - else: - return _health_pb2.HealthCheckResponse(status=status) - - # pylint: disable=arguments-differ - def Watch(self, request, context, send_response_callback=None): - blocking_watcher = None - if send_response_callback is None: - # The server does not support the experimental_non_blocking - # parameter. For backwards compatibility, return a blocking response - # generator. - blocking_watcher = _Watcher() - send_response_callback = _watcher_to_send_response_callback_adapter( - blocking_watcher) - service = request.service - with self._lock: - status = self._server_status.get(service) - if status is None: - status = _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN # pylint: disable=no-member - send_response_callback( - _health_pb2.HealthCheckResponse(status=status)) - if service not in self._send_response_callbacks: - self._send_response_callbacks[service] = set() - self._send_response_callbacks[service].add(send_response_callback) - context.add_callback( - self._on_close_callback(send_response_callback, service)) - return blocking_watcher - - def set(self, service, status): - """Sets the status of a service. - - Args: - service: string, the name of the service. - status: HealthCheckResponse.status enum value indicating the status of - the service - """ - with self._lock: - if self._gracefully_shutting_down: - return - else: - self._server_status[service] = status - if service in self._send_response_callbacks: - for send_response_callback in self._send_response_callbacks[ - service]: - send_response_callback( - _health_pb2.HealthCheckResponse(status=status)) - - def enter_graceful_shutdown(self): - """Permanently sets the status of all services to NOT_SERVING. - - This should be invoked when the server is entering a graceful shutdown - period. After this method is invoked, future attempts to set the status - of a service will be ignored. - - This is an EXPERIMENTAL API. - """ - with self._lock: - if self._gracefully_shutting_down: - return - else: - for service in self._server_status: - self.set(service, - _health_pb2.HealthCheckResponse.NOT_SERVING) # pylint: disable=no-member - self._gracefully_shutting_down = True diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/README.rst b/contrib/libs/grpc/src/python/grpcio_reflection/README.rst deleted file mode 100644 index f8c4c54866..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/README.rst +++ /dev/null @@ -1,14 +0,0 @@ -gRPC Python Reflection package -============================== - -Reference package for reflection in GRPC Python. - -Supported Python Versions -------------------------- -Python >= 3.6 - -Dependencies ------------- - -Depends on the `grpcio` package, available from PyPI via `pip install grpcio`. - diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/__init__.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/__init__.py deleted file mode 100644 index 5772620b60..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2016 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/__init__.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/__init__.py deleted file mode 100644 index 5772620b60..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2016 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py deleted file mode 100644 index c23f3a248b..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2020 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""The AsyncIO version of the reflection servicer.""" - -from typing import AsyncIterable - -import grpc -from src.proto.grpc.reflection.v1alpha import reflection_pb2 as _reflection_pb2 -from grpc_reflection.v1alpha._base import BaseReflectionServicer - - -class ReflectionServicer(BaseReflectionServicer): - """Servicer handling RPCs for service statuses.""" - - async def ServerReflectionInfo( - self, request_iterator: AsyncIterable[ - _reflection_pb2.ServerReflectionRequest], unused_context - ) -> AsyncIterable[_reflection_pb2.ServerReflectionResponse]: - async for request in request_iterator: - if request.HasField('file_by_filename'): - yield self._file_by_filename(request.file_by_filename) - elif request.HasField('file_containing_symbol'): - yield self._file_containing_symbol( - request.file_containing_symbol) - elif request.HasField('file_containing_extension'): - yield self._file_containing_extension( - request.file_containing_extension.containing_type, - request.file_containing_extension.extension_number) - elif request.HasField('all_extension_numbers_of_type'): - yield self._all_extension_numbers_of_type( - request.all_extension_numbers_of_type) - elif request.HasField('list_services'): - yield self._list_services() - else: - yield _reflection_pb2.ServerReflectionResponse( - error_response=_reflection_pb2.ErrorResponse( - error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0], - error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1]. - encode(), - )) - - -__all__ = [ - "ReflectionServicer", -] diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py deleted file mode 100644 index 5ba1925618..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright 2020 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Base implementation of reflection servicer.""" - -from google.protobuf import descriptor_pb2 -from google.protobuf import descriptor_pool -import grpc -from src.proto.grpc.reflection.v1alpha import reflection_pb2 as _reflection_pb2 -from src.proto.grpc.reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc - -_POOL = descriptor_pool.Default() - - -def _not_found_error(): - return _reflection_pb2.ServerReflectionResponse( - error_response=_reflection_pb2.ErrorResponse( - error_code=grpc.StatusCode.NOT_FOUND.value[0], - error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(), - )) - - -def _file_descriptor_response(descriptor): - proto = descriptor_pb2.FileDescriptorProto() - descriptor.CopyToProto(proto) - serialized_proto = proto.SerializeToString() - return _reflection_pb2.ServerReflectionResponse( - file_descriptor_response=_reflection_pb2.FileDescriptorResponse( - file_descriptor_proto=(serialized_proto,)),) - - -class BaseReflectionServicer(_reflection_pb2_grpc.ServerReflectionServicer): - """Base class for reflection servicer.""" - - def __init__(self, service_names, pool=None): - """Constructor. - - Args: - service_names: Iterable of fully-qualified service names available. - pool: An optional DescriptorPool instance. - """ - self._service_names = tuple(sorted(service_names)) - self._pool = _POOL if pool is None else pool - - def _file_by_filename(self, filename): - try: - descriptor = self._pool.FindFileByName(filename) - except KeyError: - return _not_found_error() - else: - return _file_descriptor_response(descriptor) - - def _file_containing_symbol(self, fully_qualified_name): - try: - descriptor = self._pool.FindFileContainingSymbol( - fully_qualified_name) - except KeyError: - return _not_found_error() - else: - return _file_descriptor_response(descriptor) - - def _file_containing_extension(self, containing_type, extension_number): - try: - message_descriptor = self._pool.FindMessageTypeByName( - containing_type) - extension_descriptor = self._pool.FindExtensionByNumber( - message_descriptor, extension_number) - descriptor = self._pool.FindFileContainingSymbol( - extension_descriptor.full_name) - except KeyError: - return _not_found_error() - else: - return _file_descriptor_response(descriptor) - - def _all_extension_numbers_of_type(self, containing_type): - try: - message_descriptor = self._pool.FindMessageTypeByName( - containing_type) - extension_numbers = tuple( - sorted(extension.number for extension in - self._pool.FindAllExtensions(message_descriptor))) - except KeyError: - return _not_found_error() - else: - return _reflection_pb2.ServerReflectionResponse( - all_extension_numbers_response=_reflection_pb2. - ExtensionNumberResponse( - base_type_name=message_descriptor.full_name, - extension_number=extension_numbers)) - - def _list_services(self): - return _reflection_pb2.ServerReflectionResponse( - list_services_response=_reflection_pb2.ListServiceResponse(service=[ - _reflection_pb2.ServiceResponse(name=service_name) - for service_name in self._service_names - ])) - - -__all__ = ['BaseReflectionServicer'] diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py deleted file mode 100644 index fe2c70ab4f..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 2016 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Reference implementation for reflection in gRPC Python.""" - -import sys - -import grpc -from src.proto.grpc.reflection.v1alpha import reflection_pb2 as _reflection_pb2 -from src.proto.grpc.reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc -from grpc_reflection.v1alpha._base import BaseReflectionServicer - -SERVICE_NAME = _reflection_pb2.DESCRIPTOR.services_by_name[ - 'ServerReflection'].full_name - - -class ReflectionServicer(BaseReflectionServicer): - """Servicer handling RPCs for service statuses.""" - - def ServerReflectionInfo(self, request_iterator, context): - # pylint: disable=unused-argument - for request in request_iterator: - if request.HasField('file_by_filename'): - yield self._file_by_filename(request.file_by_filename) - elif request.HasField('file_containing_symbol'): - yield self._file_containing_symbol( - request.file_containing_symbol) - elif request.HasField('file_containing_extension'): - yield self._file_containing_extension( - request.file_containing_extension.containing_type, - request.file_containing_extension.extension_number) - elif request.HasField('all_extension_numbers_of_type'): - yield self._all_extension_numbers_of_type( - request.all_extension_numbers_of_type) - elif request.HasField('list_services'): - yield self._list_services() - else: - yield _reflection_pb2.ServerReflectionResponse( - error_response=_reflection_pb2.ErrorResponse( - error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0], - error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1]. - encode(), - )) - - -_enable_server_reflection_doc = """Enables server reflection on a server. - -Args: - service_names: Iterable of fully-qualified service names available. - server: grpc.Server to which reflection service will be added. - pool: DescriptorPool object to use (descriptor_pool.Default() if None). -""" - -if sys.version_info[0] >= 3 and sys.version_info[1] >= 6: - # Exposes AsyncReflectionServicer as public API. - from grpc.experimental import aio as grpc_aio # pylint: disable=ungrouped-imports - - from . import _async as aio - - def enable_server_reflection(service_names, server, pool=None): - if isinstance(server, grpc_aio.Server): - _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( - aio.ReflectionServicer(service_names, pool=pool), server) - else: - _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( - ReflectionServicer(service_names, pool=pool), server) - - enable_server_reflection.__doc__ = _enable_server_reflection_doc - - __all__ = [ - "SERVICE_NAME", - "ReflectionServicer", - "enable_server_reflection", - "aio", - ] -else: - - def enable_server_reflection(service_names, server, pool=None): - _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( - ReflectionServicer(service_names, pool=pool), server) - - enable_server_reflection.__doc__ = _enable_server_reflection_doc - - __all__ = [ - "SERVICE_NAME", - "ReflectionServicer", - "enable_server_reflection", - ] diff --git a/contrib/libs/grpc/src/python/grpcio_status/README.rst b/contrib/libs/grpc/src/python/grpcio_status/README.rst deleted file mode 100644 index e9483d033f..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/README.rst +++ /dev/null @@ -1,13 +0,0 @@ -gRPC Python Status Proto -=========================== - -Reference package for GRPC Python status proto mapping. - -Supported Python Versions -------------------------- -Python >= 3.6 - -Dependencies ------------- - -Depends on the `grpcio` package, available from PyPI via `pip install grpcio`. diff --git a/contrib/libs/grpc/src/python/grpcio_status/grpc_status/__init__.py b/contrib/libs/grpc/src/python/grpcio_status/grpc_status/__init__.py deleted file mode 100644 index 38fdfc9c5c..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/grpc_status/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2018 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio_status/grpc_status/_async.py b/contrib/libs/grpc/src/python/grpcio_status/grpc_status/_async.py deleted file mode 100644 index bbd3be8971..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/grpc_status/_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2020 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Reference implementation for status mapping in gRPC Python.""" - -from google.rpc import status_pb2 -from grpc.experimental import aio - -from ._common import GRPC_DETAILS_METADATA_KEY -from ._common import code_to_grpc_status_code - - -async def from_call(call: aio.Call): - """Returns a google.rpc.status.Status message from a given grpc.aio.Call. - - This is an EXPERIMENTAL API. - - Args: - call: An grpc.aio.Call instance. - - Returns: - A google.rpc.status.Status message representing the status of the RPC. - """ - code = await call.code() - details = await call.details() - trailing_metadata = await call.trailing_metadata() - if trailing_metadata is None: - return None - for key, value in trailing_metadata: - if key == GRPC_DETAILS_METADATA_KEY: - rich_status = status_pb2.Status.FromString(value) - if code.value[0] != rich_status.code: - raise ValueError( - 'Code in Status proto (%s) doesn\'t match status code (%s)' - % (code_to_grpc_status_code(rich_status.code), code)) - if details != rich_status.message: - raise ValueError( - 'Message in Status proto (%s) doesn\'t match status details (%s)' - % (rich_status.message, details)) - return rich_status - return None - - -__all__ = [ - 'from_call', -] diff --git a/contrib/libs/grpc/src/python/grpcio_status/grpc_status/_common.py b/contrib/libs/grpc/src/python/grpcio_status/grpc_status/_common.py deleted file mode 100644 index 4bec0ba137..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/grpc_status/_common.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2020 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Reference implementation for status mapping in gRPC Python.""" - -import grpc - -_CODE_TO_GRPC_CODE_MAPPING = {x.value[0]: x for x in grpc.StatusCode} - -GRPC_DETAILS_METADATA_KEY = 'grpc-status-details-bin' - - -def code_to_grpc_status_code(code): - try: - return _CODE_TO_GRPC_CODE_MAPPING[code] - except KeyError: - raise ValueError('Invalid status code %s' % code) diff --git a/contrib/libs/grpc/src/python/grpcio_status/grpc_status/rpc_status.py b/contrib/libs/grpc/src/python/grpcio_status/grpc_status/rpc_status.py deleted file mode 100644 index 432e414f70..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/grpc_status/rpc_status.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright 2018 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Reference implementation for status mapping in gRPC Python.""" - -import collections -import sys - -from google.rpc import status_pb2 -import grpc - -from ._common import GRPC_DETAILS_METADATA_KEY -from ._common import code_to_grpc_status_code - - -class _Status( - collections.namedtuple('_Status', - ('code', 'details', 'trailing_metadata')), - grpc.Status): - pass - - -def from_call(call): - """Returns a google.rpc.status.Status message corresponding to a given grpc.Call. - - This is an EXPERIMENTAL API. - - Args: - call: A grpc.Call instance. - - Returns: - A google.rpc.status.Status message representing the status of the RPC. - - Raises: - ValueError: If the gRPC call's code or details are inconsistent with the - status code and message inside of the google.rpc.status.Status. - """ - if call.trailing_metadata() is None: - return None - for key, value in call.trailing_metadata(): - if key == GRPC_DETAILS_METADATA_KEY: - rich_status = status_pb2.Status.FromString(value) - if call.code().value[0] != rich_status.code: - raise ValueError( - 'Code in Status proto (%s) doesn\'t match status code (%s)' - % (code_to_grpc_status_code(rich_status.code), call.code())) - if call.details() != rich_status.message: - raise ValueError( - 'Message in Status proto (%s) doesn\'t match status details (%s)' - % (rich_status.message, call.details())) - return rich_status - return None - - -def to_status(status): - """Convert a google.rpc.status.Status message to grpc.Status. - - This is an EXPERIMENTAL API. - - Args: - status: a google.rpc.status.Status message representing the non-OK status - to terminate the RPC with and communicate it to the client. - - Returns: - A grpc.Status instance representing the input google.rpc.status.Status message. - """ - return _Status(code=code_to_grpc_status_code(status.code), - details=status.message, - trailing_metadata=((GRPC_DETAILS_METADATA_KEY, - status.SerializeToString()),)) - - -__all__ = [ - 'from_call', - 'to_status', -] - -if sys.version_info[0] >= 3 and sys.version_info[1] >= 6: - from . import _async as aio # pylint: disable=unused-import - __all__.append('aio') diff --git a/contrib/libs/grpc/src/python/grpcio_testing/README.rst b/contrib/libs/grpc/src/python/grpcio_testing/README.rst deleted file mode 100644 index 66d80b1d53..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/README.rst +++ /dev/null @@ -1,14 +0,0 @@ -gRPC Python Testing Package -=========================== - -Testing utilities for gRPC Python - -Supported Python Versions -------------------------- -Python >= 3.6 - -Dependencies ------------- - -Depends on the `grpcio` package, available from PyPI via `pip install grpcio`. - |