grpcio-fips 1.70.0__3-cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- grpc/__init__.py +2348 -0
- grpc/_auth.py +80 -0
- grpc/_channel.py +2267 -0
- grpc/_common.py +183 -0
- grpc/_compression.py +71 -0
- grpc/_cython/__init__.py +13 -0
- grpc/_cython/_credentials/roots.pem +4337 -0
- grpc/_cython/_cygrpc/__init__.py +13 -0
- grpc/_cython/cygrpc.cp313-win_amd64.pyd +0 -0
- grpc/_grpcio_metadata.py +1 -0
- grpc/_interceptor.py +813 -0
- grpc/_observability.py +299 -0
- grpc/_plugin_wrapping.py +136 -0
- grpc/_runtime_protos.py +165 -0
- grpc/_server.py +1528 -0
- grpc/_simple_stubs.py +588 -0
- grpc/_typing.py +95 -0
- grpc/_utilities.py +222 -0
- grpc/aio/__init__.py +95 -0
- grpc/aio/_base_call.py +257 -0
- grpc/aio/_base_channel.py +364 -0
- grpc/aio/_base_server.py +385 -0
- grpc/aio/_call.py +764 -0
- grpc/aio/_channel.py +627 -0
- grpc/aio/_interceptor.py +1178 -0
- grpc/aio/_metadata.py +137 -0
- grpc/aio/_server.py +239 -0
- grpc/aio/_typing.py +43 -0
- grpc/aio/_utils.py +22 -0
- grpc/beta/__init__.py +13 -0
- grpc/beta/_client_adaptations.py +1015 -0
- grpc/beta/_metadata.py +56 -0
- grpc/beta/_server_adaptations.py +465 -0
- grpc/beta/implementations.py +345 -0
- grpc/beta/interfaces.py +163 -0
- grpc/beta/utilities.py +153 -0
- grpc/experimental/__init__.py +134 -0
- grpc/experimental/aio/__init__.py +16 -0
- grpc/experimental/gevent.py +27 -0
- grpc/experimental/session_cache.py +45 -0
- grpc/framework/__init__.py +13 -0
- grpc/framework/common/__init__.py +13 -0
- grpc/framework/common/cardinality.py +26 -0
- grpc/framework/common/style.py +24 -0
- grpc/framework/foundation/__init__.py +13 -0
- grpc/framework/foundation/abandonment.py +22 -0
- grpc/framework/foundation/callable_util.py +98 -0
- grpc/framework/foundation/future.py +219 -0
- grpc/framework/foundation/logging_pool.py +72 -0
- grpc/framework/foundation/stream.py +43 -0
- grpc/framework/foundation/stream_util.py +148 -0
- grpc/framework/interfaces/__init__.py +13 -0
- grpc/framework/interfaces/base/__init__.py +13 -0
- grpc/framework/interfaces/base/base.py +328 -0
- grpc/framework/interfaces/base/utilities.py +83 -0
- grpc/framework/interfaces/face/__init__.py +13 -0
- grpc/framework/interfaces/face/face.py +1084 -0
- grpc/framework/interfaces/face/utilities.py +245 -0
- grpcio_fips-1.70.0.dist-info/METADATA +142 -0
- grpcio_fips-1.70.0.dist-info/RECORD +63 -0
- grpcio_fips-1.70.0.dist-info/WHEEL +5 -0
- grpcio_fips-1.70.0.dist-info/licenses/LICENSE +610 -0
- grpcio_fips-1.70.0.dist-info/top_level.txt +1 -0
grpc/aio/_metadata.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Copyright 2020 gRPC authors.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
"""Implementation of the metadata abstraction for gRPC Asyncio Python."""
|
|
15
|
+
from collections import OrderedDict
|
|
16
|
+
from collections import abc
|
|
17
|
+
from typing import Any, Iterator, List, Optional, Tuple, Union
|
|
18
|
+
|
|
19
|
+
MetadataKey = str
|
|
20
|
+
MetadataValue = Union[str, bytes]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Metadata(abc.Collection):
|
|
24
|
+
"""Metadata abstraction for the asynchronous calls and interceptors.
|
|
25
|
+
|
|
26
|
+
The metadata is a mapping from str -> List[str]
|
|
27
|
+
|
|
28
|
+
Traits
|
|
29
|
+
* Multiple entries are allowed for the same key
|
|
30
|
+
* The order of the values by key is preserved
|
|
31
|
+
* Getting by an element by key, retrieves the first mapped value
|
|
32
|
+
* Supports an immutable view of the data
|
|
33
|
+
* Allows partial mutation on the data without recreating the new object from scratch.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, *args: Tuple[MetadataKey, MetadataValue]) -> None:
|
|
37
|
+
self._metadata = OrderedDict()
|
|
38
|
+
for md_key, md_value in args:
|
|
39
|
+
self.add(md_key, md_value)
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def from_tuple(cls, raw_metadata: tuple):
|
|
43
|
+
if raw_metadata:
|
|
44
|
+
return cls(*raw_metadata)
|
|
45
|
+
return cls()
|
|
46
|
+
|
|
47
|
+
def add(self, key: MetadataKey, value: MetadataValue) -> None:
|
|
48
|
+
self._metadata.setdefault(key, [])
|
|
49
|
+
self._metadata[key].append(value)
|
|
50
|
+
|
|
51
|
+
def __len__(self) -> int:
|
|
52
|
+
"""Return the total number of elements that there are in the metadata,
|
|
53
|
+
including multiple values for the same key.
|
|
54
|
+
"""
|
|
55
|
+
return sum(map(len, self._metadata.values()))
|
|
56
|
+
|
|
57
|
+
def __getitem__(self, key: MetadataKey) -> MetadataValue:
|
|
58
|
+
"""When calling <metadata>[<key>], the first element of all those
|
|
59
|
+
mapped for <key> is returned.
|
|
60
|
+
"""
|
|
61
|
+
try:
|
|
62
|
+
return self._metadata[key][0]
|
|
63
|
+
except (ValueError, IndexError) as e:
|
|
64
|
+
raise KeyError("{0!r}".format(key)) from e
|
|
65
|
+
|
|
66
|
+
def __setitem__(self, key: MetadataKey, value: MetadataValue) -> None:
|
|
67
|
+
"""Calling metadata[<key>] = <value>
|
|
68
|
+
Maps <value> to the first instance of <key>.
|
|
69
|
+
"""
|
|
70
|
+
if key not in self:
|
|
71
|
+
self._metadata[key] = [value]
|
|
72
|
+
else:
|
|
73
|
+
current_values = self.get_all(key)
|
|
74
|
+
self._metadata[key] = [value, *current_values[1:]]
|
|
75
|
+
|
|
76
|
+
def __delitem__(self, key: MetadataKey) -> None:
|
|
77
|
+
"""``del metadata[<key>]`` deletes the first mapping for <key>."""
|
|
78
|
+
current_values = self.get_all(key)
|
|
79
|
+
if not current_values:
|
|
80
|
+
raise KeyError(repr(key))
|
|
81
|
+
self._metadata[key] = current_values[1:]
|
|
82
|
+
|
|
83
|
+
def delete_all(self, key: MetadataKey) -> None:
|
|
84
|
+
"""Delete all mappings for <key>."""
|
|
85
|
+
del self._metadata[key]
|
|
86
|
+
|
|
87
|
+
def __iter__(self) -> Iterator[Tuple[MetadataKey, MetadataValue]]:
|
|
88
|
+
for key, values in self._metadata.items():
|
|
89
|
+
for value in values:
|
|
90
|
+
yield (key, value)
|
|
91
|
+
|
|
92
|
+
def keys(self) -> abc.KeysView:
|
|
93
|
+
return abc.KeysView(self)
|
|
94
|
+
|
|
95
|
+
def values(self) -> abc.ValuesView:
|
|
96
|
+
return abc.ValuesView(self)
|
|
97
|
+
|
|
98
|
+
def items(self) -> abc.ItemsView:
|
|
99
|
+
return abc.ItemsView(self)
|
|
100
|
+
|
|
101
|
+
def get(
|
|
102
|
+
self, key: MetadataKey, default: MetadataValue = None
|
|
103
|
+
) -> Optional[MetadataValue]:
|
|
104
|
+
try:
|
|
105
|
+
return self[key]
|
|
106
|
+
except KeyError:
|
|
107
|
+
return default
|
|
108
|
+
|
|
109
|
+
def get_all(self, key: MetadataKey) -> List[MetadataValue]:
|
|
110
|
+
"""For compatibility with other Metadata abstraction objects (like in Java),
|
|
111
|
+
this would return all items under the desired <key>.
|
|
112
|
+
"""
|
|
113
|
+
return self._metadata.get(key, [])
|
|
114
|
+
|
|
115
|
+
def set_all(self, key: MetadataKey, values: List[MetadataValue]) -> None:
|
|
116
|
+
self._metadata[key] = values
|
|
117
|
+
|
|
118
|
+
def __contains__(self, key: MetadataKey) -> bool:
|
|
119
|
+
return key in self._metadata
|
|
120
|
+
|
|
121
|
+
def __eq__(self, other: Any) -> bool:
|
|
122
|
+
if isinstance(other, self.__class__):
|
|
123
|
+
return self._metadata == other._metadata
|
|
124
|
+
if isinstance(other, tuple):
|
|
125
|
+
return tuple(self) == other
|
|
126
|
+
return NotImplemented # pytype: disable=bad-return-type
|
|
127
|
+
|
|
128
|
+
def __add__(self, other: Any) -> "Metadata":
|
|
129
|
+
if isinstance(other, self.__class__):
|
|
130
|
+
return Metadata(*(tuple(self) + tuple(other)))
|
|
131
|
+
if isinstance(other, tuple):
|
|
132
|
+
return Metadata(*(tuple(self) + other))
|
|
133
|
+
return NotImplemented # pytype: disable=bad-return-type
|
|
134
|
+
|
|
135
|
+
def __repr__(self) -> str:
|
|
136
|
+
view = tuple(self)
|
|
137
|
+
return "{0}({1!r})".format(self.__class__.__name__, view)
|
grpc/aio/_server.py
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Copyright 2019 The gRPC Authors
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
"""Server-side implementation of gRPC Asyncio Python."""
|
|
15
|
+
|
|
16
|
+
from concurrent.futures import Executor
|
|
17
|
+
from typing import Any, Dict, Optional, Sequence
|
|
18
|
+
|
|
19
|
+
import grpc
|
|
20
|
+
from grpc import _common
|
|
21
|
+
from grpc import _compression
|
|
22
|
+
from grpc._cython import cygrpc
|
|
23
|
+
|
|
24
|
+
from . import _base_server
|
|
25
|
+
from ._interceptor import ServerInterceptor
|
|
26
|
+
from ._typing import ChannelArgumentType
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _augment_channel_arguments(
|
|
30
|
+
base_options: ChannelArgumentType, compression: Optional[grpc.Compression]
|
|
31
|
+
):
|
|
32
|
+
compression_option = _compression.create_channel_option(compression)
|
|
33
|
+
return tuple(base_options) + compression_option
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Server(_base_server.Server):
|
|
37
|
+
"""Serves RPCs."""
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
thread_pool: Optional[Executor],
|
|
42
|
+
generic_handlers: Optional[Sequence[grpc.GenericRpcHandler]],
|
|
43
|
+
interceptors: Optional[Sequence[Any]],
|
|
44
|
+
options: ChannelArgumentType,
|
|
45
|
+
maximum_concurrent_rpcs: Optional[int],
|
|
46
|
+
compression: Optional[grpc.Compression],
|
|
47
|
+
):
|
|
48
|
+
self._loop = cygrpc.get_working_loop()
|
|
49
|
+
if interceptors:
|
|
50
|
+
invalid_interceptors = [
|
|
51
|
+
interceptor
|
|
52
|
+
for interceptor in interceptors
|
|
53
|
+
if not isinstance(interceptor, ServerInterceptor)
|
|
54
|
+
]
|
|
55
|
+
if invalid_interceptors:
|
|
56
|
+
raise ValueError(
|
|
57
|
+
"Interceptor must be ServerInterceptor, the "
|
|
58
|
+
f"following are invalid: {invalid_interceptors}"
|
|
59
|
+
)
|
|
60
|
+
self._server = cygrpc.AioServer(
|
|
61
|
+
self._loop,
|
|
62
|
+
thread_pool,
|
|
63
|
+
generic_handlers,
|
|
64
|
+
interceptors,
|
|
65
|
+
_augment_channel_arguments(options, compression),
|
|
66
|
+
maximum_concurrent_rpcs,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def add_generic_rpc_handlers(
|
|
70
|
+
self, generic_rpc_handlers: Sequence[grpc.GenericRpcHandler]
|
|
71
|
+
) -> None:
|
|
72
|
+
"""Registers GenericRpcHandlers with this Server.
|
|
73
|
+
|
|
74
|
+
This method is only safe to call before the server is started.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
generic_rpc_handlers: A sequence of GenericRpcHandlers that will be
|
|
78
|
+
used to service RPCs.
|
|
79
|
+
"""
|
|
80
|
+
self._server.add_generic_rpc_handlers(generic_rpc_handlers)
|
|
81
|
+
|
|
82
|
+
def add_registered_method_handlers(
|
|
83
|
+
self,
|
|
84
|
+
service_name: str,
|
|
85
|
+
method_handlers: Dict[str, grpc.RpcMethodHandler],
|
|
86
|
+
) -> None:
|
|
87
|
+
# TODO(xuanwn): Implement this for AsyncIO.
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
def add_insecure_port(self, address: str) -> int:
|
|
91
|
+
"""Opens an insecure port for accepting RPCs.
|
|
92
|
+
|
|
93
|
+
This method may only be called before starting the server.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
address: The address for which to open a port. If the port is 0,
|
|
97
|
+
or not specified in the address, then the gRPC runtime will choose a port.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
An integer port on which the server will accept RPC requests.
|
|
101
|
+
"""
|
|
102
|
+
return _common.validate_port_binding_result(
|
|
103
|
+
address, self._server.add_insecure_port(_common.encode(address))
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def add_secure_port(
|
|
107
|
+
self, address: str, server_credentials: grpc.ServerCredentials
|
|
108
|
+
) -> int:
|
|
109
|
+
"""Opens a secure port for accepting RPCs.
|
|
110
|
+
|
|
111
|
+
This method may only be called before starting the server.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
address: The address for which to open a port.
|
|
115
|
+
if the port is 0, or not specified in the address, then the gRPC
|
|
116
|
+
runtime will choose a port.
|
|
117
|
+
server_credentials: A ServerCredentials object.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
An integer port on which the server will accept RPC requests.
|
|
121
|
+
"""
|
|
122
|
+
return _common.validate_port_binding_result(
|
|
123
|
+
address,
|
|
124
|
+
self._server.add_secure_port(
|
|
125
|
+
_common.encode(address), server_credentials
|
|
126
|
+
),
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
async def start(self) -> None:
|
|
130
|
+
"""Starts this Server.
|
|
131
|
+
|
|
132
|
+
This method may only be called once. (i.e. it is not idempotent).
|
|
133
|
+
"""
|
|
134
|
+
await self._server.start()
|
|
135
|
+
|
|
136
|
+
async def stop(self, grace: Optional[float]) -> None:
|
|
137
|
+
"""Stops this Server.
|
|
138
|
+
|
|
139
|
+
This method immediately stops the server from servicing new RPCs in
|
|
140
|
+
all cases.
|
|
141
|
+
|
|
142
|
+
If a grace period is specified, this method waits until all active
|
|
143
|
+
RPCs are finished or until the grace period is reached. RPCs that haven't
|
|
144
|
+
been terminated within the grace period are aborted.
|
|
145
|
+
If a grace period is not specified (by passing None for grace), all
|
|
146
|
+
existing RPCs are aborted immediately and this method blocks until
|
|
147
|
+
the last RPC handler terminates.
|
|
148
|
+
|
|
149
|
+
This method is idempotent and may be called at any time. Passing a
|
|
150
|
+
smaller grace value in a subsequent call will have the effect of
|
|
151
|
+
stopping the Server sooner (passing None will have the effect of
|
|
152
|
+
stopping the server immediately). Passing a larger grace value in a
|
|
153
|
+
subsequent call will not have the effect of stopping the server later
|
|
154
|
+
(i.e. the most restrictive grace value is used).
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
grace: A duration of time in seconds or None.
|
|
158
|
+
"""
|
|
159
|
+
await self._server.shutdown(grace)
|
|
160
|
+
|
|
161
|
+
async def wait_for_termination(
|
|
162
|
+
self, timeout: Optional[float] = None
|
|
163
|
+
) -> bool:
|
|
164
|
+
"""Block current coroutine until the server stops.
|
|
165
|
+
|
|
166
|
+
This is an EXPERIMENTAL API.
|
|
167
|
+
|
|
168
|
+
The wait will not consume computational resources during blocking, and
|
|
169
|
+
it will block until one of the two following conditions are met:
|
|
170
|
+
|
|
171
|
+
1) The server is stopped or terminated;
|
|
172
|
+
2) A timeout occurs if timeout is not `None`.
|
|
173
|
+
|
|
174
|
+
The timeout argument works in the same way as `threading.Event.wait()`.
|
|
175
|
+
https://docs.python.org/3/library/threading.html#threading.Event.wait
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
timeout: A floating point number specifying a timeout for the
|
|
179
|
+
operation in seconds.
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
A bool indicates if the operation times out.
|
|
183
|
+
"""
|
|
184
|
+
return await self._server.wait_for_termination(timeout)
|
|
185
|
+
|
|
186
|
+
def __del__(self):
|
|
187
|
+
"""Schedules a graceful shutdown in current event loop.
|
|
188
|
+
|
|
189
|
+
The Cython AioServer doesn't hold a ref-count to this class. It should
|
|
190
|
+
be safe to slightly extend the underlying Cython object's life span.
|
|
191
|
+
"""
|
|
192
|
+
if hasattr(self, "_server"):
|
|
193
|
+
if self._server.is_running():
|
|
194
|
+
cygrpc.schedule_coro_threadsafe(
|
|
195
|
+
self._server.shutdown(None),
|
|
196
|
+
self._loop,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def server(
|
|
201
|
+
migration_thread_pool: Optional[Executor] = None,
|
|
202
|
+
handlers: Optional[Sequence[grpc.GenericRpcHandler]] = None,
|
|
203
|
+
interceptors: Optional[Sequence[Any]] = None,
|
|
204
|
+
options: Optional[ChannelArgumentType] = None,
|
|
205
|
+
maximum_concurrent_rpcs: Optional[int] = None,
|
|
206
|
+
compression: Optional[grpc.Compression] = None,
|
|
207
|
+
):
|
|
208
|
+
"""Creates a Server with which RPCs can be serviced.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
migration_thread_pool: A futures.ThreadPoolExecutor to be used by the
|
|
212
|
+
Server to execute non-AsyncIO RPC handlers for migration purpose.
|
|
213
|
+
handlers: An optional list of GenericRpcHandlers used for executing RPCs.
|
|
214
|
+
More handlers may be added by calling add_generic_rpc_handlers any time
|
|
215
|
+
before the server is started.
|
|
216
|
+
interceptors: An optional list of ServerInterceptor objects that observe
|
|
217
|
+
and optionally manipulate the incoming RPCs before handing them over to
|
|
218
|
+
handlers. The interceptors are given control in the order they are
|
|
219
|
+
specified. This is an EXPERIMENTAL API.
|
|
220
|
+
options: An optional list of key-value pairs (:term:`channel_arguments` in gRPC runtime)
|
|
221
|
+
to configure the channel.
|
|
222
|
+
maximum_concurrent_rpcs: The maximum number of concurrent RPCs this server
|
|
223
|
+
will service before returning RESOURCE_EXHAUSTED status, or None to
|
|
224
|
+
indicate no limit.
|
|
225
|
+
compression: An element of grpc.compression, e.g.
|
|
226
|
+
grpc.compression.Gzip. This compression algorithm will be used for the
|
|
227
|
+
lifetime of the server unless overridden by set_compression.
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
A Server object.
|
|
231
|
+
"""
|
|
232
|
+
return Server(
|
|
233
|
+
migration_thread_pool,
|
|
234
|
+
() if handlers is None else handlers,
|
|
235
|
+
() if interceptors is None else interceptors,
|
|
236
|
+
() if options is None else options,
|
|
237
|
+
maximum_concurrent_rpcs,
|
|
238
|
+
compression,
|
|
239
|
+
)
|
grpc/aio/_typing.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Copyright 2019 The gRPC Authors
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
"""Common types for gRPC Async API"""
|
|
15
|
+
|
|
16
|
+
from typing import (
|
|
17
|
+
Any,
|
|
18
|
+
AsyncIterable,
|
|
19
|
+
Callable,
|
|
20
|
+
Iterable,
|
|
21
|
+
Sequence,
|
|
22
|
+
Tuple,
|
|
23
|
+
TypeVar,
|
|
24
|
+
Union,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
from grpc._cython.cygrpc import EOF
|
|
28
|
+
|
|
29
|
+
from ._metadata import Metadata
|
|
30
|
+
from ._metadata import MetadataKey
|
|
31
|
+
from ._metadata import MetadataValue
|
|
32
|
+
|
|
33
|
+
RequestType = TypeVar("RequestType")
|
|
34
|
+
ResponseType = TypeVar("ResponseType")
|
|
35
|
+
SerializingFunction = Callable[[Any], bytes]
|
|
36
|
+
DeserializingFunction = Callable[[bytes], Any]
|
|
37
|
+
MetadatumType = Tuple[MetadataKey, MetadataValue]
|
|
38
|
+
MetadataType = Union[Metadata, Sequence[MetadatumType]]
|
|
39
|
+
ChannelArgumentType = Sequence[Tuple[str, Any]]
|
|
40
|
+
EOFType = type(EOF)
|
|
41
|
+
DoneCallbackType = Callable[[Any], None]
|
|
42
|
+
RequestIterableType = Union[Iterable[Any], AsyncIterable[Any]]
|
|
43
|
+
ResponseIterableType = AsyncIterable[Any]
|
grpc/aio/_utils.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2019 gRPC authors.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
"""Internal utilities used by the gRPC Aio module."""
|
|
15
|
+
import time
|
|
16
|
+
from typing import Optional
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _timeout_to_deadline(timeout: Optional[float]) -> Optional[float]:
|
|
20
|
+
if timeout is None:
|
|
21
|
+
return None
|
|
22
|
+
return time.time() + timeout
|
grpc/beta/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|