grpcio-fips 1.53.2__0-cp38-cp38-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.
Files changed (62) hide show
  1. grpc/__init__.py +2174 -0
  2. grpc/_auth.py +68 -0
  3. grpc/_channel.py +1767 -0
  4. grpc/_common.py +177 -0
  5. grpc/_compression.py +63 -0
  6. grpc/_cython/__init__.py +13 -0
  7. grpc/_cython/_credentials/roots.pem +4337 -0
  8. grpc/_cython/_cygrpc/__init__.py +13 -0
  9. grpc/_cython/cygrpc.cp38-win_amd64.pyd +0 -0
  10. grpc/_grpcio_metadata.py +1 -0
  11. grpc/_interceptor.py +638 -0
  12. grpc/_plugin_wrapping.py +121 -0
  13. grpc/_runtime_protos.py +159 -0
  14. grpc/_server.py +1141 -0
  15. grpc/_simple_stubs.py +486 -0
  16. grpc/_typing.py +58 -0
  17. grpc/_utilities.py +180 -0
  18. grpc/aio/__init__.py +95 -0
  19. grpc/aio/_base_call.py +248 -0
  20. grpc/aio/_base_channel.py +348 -0
  21. grpc/aio/_base_server.py +369 -0
  22. grpc/aio/_call.py +649 -0
  23. grpc/aio/_channel.py +492 -0
  24. grpc/aio/_interceptor.py +1003 -0
  25. grpc/aio/_metadata.py +120 -0
  26. grpc/aio/_server.py +209 -0
  27. grpc/aio/_typing.py +35 -0
  28. grpc/aio/_utils.py +22 -0
  29. grpc/beta/__init__.py +13 -0
  30. grpc/beta/_client_adaptations.py +706 -0
  31. grpc/beta/_metadata.py +52 -0
  32. grpc/beta/_server_adaptations.py +385 -0
  33. grpc/beta/implementations.py +311 -0
  34. grpc/beta/interfaces.py +163 -0
  35. grpc/beta/utilities.py +149 -0
  36. grpc/experimental/__init__.py +128 -0
  37. grpc/experimental/aio/__init__.py +16 -0
  38. grpc/experimental/gevent.py +27 -0
  39. grpc/experimental/session_cache.py +45 -0
  40. grpc/framework/__init__.py +13 -0
  41. grpc/framework/common/__init__.py +13 -0
  42. grpc/framework/common/cardinality.py +26 -0
  43. grpc/framework/common/style.py +24 -0
  44. grpc/framework/foundation/__init__.py +13 -0
  45. grpc/framework/foundation/abandonment.py +22 -0
  46. grpc/framework/foundation/callable_util.py +94 -0
  47. grpc/framework/foundation/future.py +219 -0
  48. grpc/framework/foundation/logging_pool.py +71 -0
  49. grpc/framework/foundation/stream.py +43 -0
  50. grpc/framework/foundation/stream_util.py +148 -0
  51. grpc/framework/interfaces/__init__.py +13 -0
  52. grpc/framework/interfaces/base/__init__.py +13 -0
  53. grpc/framework/interfaces/base/base.py +325 -0
  54. grpc/framework/interfaces/base/utilities.py +71 -0
  55. grpc/framework/interfaces/face/__init__.py +13 -0
  56. grpc/framework/interfaces/face/face.py +1049 -0
  57. grpc/framework/interfaces/face/utilities.py +168 -0
  58. grpcio_fips-1.53.2.dist-info/LICENSE +610 -0
  59. grpcio_fips-1.53.2.dist-info/METADATA +139 -0
  60. grpcio_fips-1.53.2.dist-info/RECORD +62 -0
  61. grpcio_fips-1.53.2.dist-info/WHEEL +5 -0
  62. grpcio_fips-1.53.2.dist-info/top_level.txt +1 -0
grpc/_common.py ADDED
@@ -0,0 +1,177 @@
1
+ # Copyright 2016 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
+ """Shared implementation."""
15
+
16
+ import logging
17
+ import time
18
+ from typing import Any, AnyStr, Callable, Optional, Union
19
+
20
+ import grpc
21
+ from grpc._cython import cygrpc
22
+ from grpc._typing import DeserializingFunction
23
+ from grpc._typing import SerializingFunction
24
+
25
+ _LOGGER = logging.getLogger(__name__)
26
+
27
+ CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY = {
28
+ cygrpc.ConnectivityState.idle:
29
+ grpc.ChannelConnectivity.IDLE,
30
+ cygrpc.ConnectivityState.connecting:
31
+ grpc.ChannelConnectivity.CONNECTING,
32
+ cygrpc.ConnectivityState.ready:
33
+ grpc.ChannelConnectivity.READY,
34
+ cygrpc.ConnectivityState.transient_failure:
35
+ grpc.ChannelConnectivity.TRANSIENT_FAILURE,
36
+ cygrpc.ConnectivityState.shutdown:
37
+ grpc.ChannelConnectivity.SHUTDOWN,
38
+ }
39
+
40
+ CYGRPC_STATUS_CODE_TO_STATUS_CODE = {
41
+ cygrpc.StatusCode.ok: grpc.StatusCode.OK,
42
+ cygrpc.StatusCode.cancelled: grpc.StatusCode.CANCELLED,
43
+ cygrpc.StatusCode.unknown: grpc.StatusCode.UNKNOWN,
44
+ cygrpc.StatusCode.invalid_argument: grpc.StatusCode.INVALID_ARGUMENT,
45
+ cygrpc.StatusCode.deadline_exceeded: grpc.StatusCode.DEADLINE_EXCEEDED,
46
+ cygrpc.StatusCode.not_found: grpc.StatusCode.NOT_FOUND,
47
+ cygrpc.StatusCode.already_exists: grpc.StatusCode.ALREADY_EXISTS,
48
+ cygrpc.StatusCode.permission_denied: grpc.StatusCode.PERMISSION_DENIED,
49
+ cygrpc.StatusCode.unauthenticated: grpc.StatusCode.UNAUTHENTICATED,
50
+ cygrpc.StatusCode.resource_exhausted: grpc.StatusCode.RESOURCE_EXHAUSTED,
51
+ cygrpc.StatusCode.failed_precondition: grpc.StatusCode.FAILED_PRECONDITION,
52
+ cygrpc.StatusCode.aborted: grpc.StatusCode.ABORTED,
53
+ cygrpc.StatusCode.out_of_range: grpc.StatusCode.OUT_OF_RANGE,
54
+ cygrpc.StatusCode.unimplemented: grpc.StatusCode.UNIMPLEMENTED,
55
+ cygrpc.StatusCode.internal: grpc.StatusCode.INTERNAL,
56
+ cygrpc.StatusCode.unavailable: grpc.StatusCode.UNAVAILABLE,
57
+ cygrpc.StatusCode.data_loss: grpc.StatusCode.DATA_LOSS,
58
+ }
59
+ STATUS_CODE_TO_CYGRPC_STATUS_CODE = {
60
+ grpc_code: cygrpc_code
61
+ for cygrpc_code, grpc_code in CYGRPC_STATUS_CODE_TO_STATUS_CODE.items()
62
+ }
63
+
64
+ MAXIMUM_WAIT_TIMEOUT = 0.1
65
+
66
+ _ERROR_MESSAGE_PORT_BINDING_FAILED = 'Failed to bind to address %s; set ' \
67
+ 'GRPC_VERBOSITY=debug environment variable to see detailed error message.'
68
+
69
+
70
+ def encode(s: AnyStr) -> bytes:
71
+ if isinstance(s, bytes):
72
+ return s
73
+ else:
74
+ return s.encode('utf8')
75
+
76
+
77
+ def decode(b: AnyStr) -> str:
78
+ if isinstance(b, bytes):
79
+ return b.decode('utf-8', 'replace')
80
+ return b
81
+
82
+
83
+ def _transform(message: Any, transformer: Union[SerializingFunction,
84
+ DeserializingFunction, None],
85
+ exception_message: str) -> Any:
86
+ if transformer is None:
87
+ return message
88
+ else:
89
+ try:
90
+ return transformer(message)
91
+ except Exception: # pylint: disable=broad-except
92
+ _LOGGER.exception(exception_message)
93
+ return None
94
+
95
+
96
+ def serialize(message: Any, serializer: Optional[SerializingFunction]) -> bytes:
97
+ return _transform(message, serializer, 'Exception serializing message!')
98
+
99
+
100
+ def deserialize(serialized_message: bytes,
101
+ deserializer: Optional[DeserializingFunction]) -> Any:
102
+ return _transform(serialized_message, deserializer,
103
+ 'Exception deserializing message!')
104
+
105
+
106
+ def fully_qualified_method(group: str, method: str) -> str:
107
+ return '/{}/{}'.format(group, method)
108
+
109
+
110
+ def _wait_once(wait_fn: Callable[..., bool], timeout: float,
111
+ spin_cb: Optional[Callable[[], None]]):
112
+ wait_fn(timeout=timeout)
113
+ if spin_cb is not None:
114
+ spin_cb()
115
+
116
+
117
+ def wait(wait_fn: Callable[..., bool],
118
+ wait_complete_fn: Callable[[], bool],
119
+ timeout: Optional[float] = None,
120
+ spin_cb: Optional[Callable[[], None]] = None) -> bool:
121
+ """Blocks waiting for an event without blocking the thread indefinitely.
122
+
123
+ See https://github.com/grpc/grpc/issues/19464 for full context. CPython's
124
+ `threading.Event.wait` and `threading.Condition.wait` methods, if invoked
125
+ without a timeout kwarg, may block the calling thread indefinitely. If the
126
+ call is made from the main thread, this means that signal handlers may not
127
+ run for an arbitrarily long period of time.
128
+
129
+ This wrapper calls the supplied wait function with an arbitrary short
130
+ timeout to ensure that no signal handler has to wait longer than
131
+ MAXIMUM_WAIT_TIMEOUT before executing.
132
+
133
+ Args:
134
+ wait_fn: A callable acceptable a single float-valued kwarg named
135
+ `timeout`. This function is expected to be one of `threading.Event.wait`
136
+ or `threading.Condition.wait`.
137
+ wait_complete_fn: A callable taking no arguments and returning a bool.
138
+ When this function returns true, it indicates that waiting should cease.
139
+ timeout: An optional float-valued number of seconds after which the wait
140
+ should cease.
141
+ spin_cb: An optional Callable taking no arguments and returning nothing.
142
+ This callback will be called on each iteration of the spin. This may be
143
+ used for, e.g. work related to forking.
144
+
145
+ Returns:
146
+ True if a timeout was supplied and it was reached. False otherwise.
147
+ """
148
+ if timeout is None:
149
+ while not wait_complete_fn():
150
+ _wait_once(wait_fn, MAXIMUM_WAIT_TIMEOUT, spin_cb)
151
+ else:
152
+ end = time.time() + timeout
153
+ while not wait_complete_fn():
154
+ remaining = min(end - time.time(), MAXIMUM_WAIT_TIMEOUT)
155
+ if remaining < 0:
156
+ return True
157
+ _wait_once(wait_fn, remaining, spin_cb)
158
+ return False
159
+
160
+
161
+ def validate_port_binding_result(address: str, port: int) -> int:
162
+ """Validates if the port binding succeed.
163
+
164
+ If the port returned by Core is 0, the binding is failed. However, in that
165
+ case, the Core API doesn't return a detailed failing reason. The best we
166
+ can do is raising an exception to prevent further confusion.
167
+
168
+ Args:
169
+ address: The address string to be bound.
170
+ port: An int returned by core
171
+ """
172
+ if port == 0:
173
+ # The Core API doesn't return a failure message. The best we can do
174
+ # is raising an exception to prevent further confusion.
175
+ raise RuntimeError(_ERROR_MESSAGE_PORT_BINDING_FAILED % address)
176
+ else:
177
+ return port
grpc/_compression.py ADDED
@@ -0,0 +1,63 @@
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
+
15
+ from __future__ import annotations
16
+
17
+ from typing import Optional
18
+
19
+ import grpc
20
+ from grpc._cython import cygrpc
21
+ from grpc._typing import MetadataType
22
+
23
+ NoCompression = cygrpc.CompressionAlgorithm.none
24
+ Deflate = cygrpc.CompressionAlgorithm.deflate
25
+ Gzip = cygrpc.CompressionAlgorithm.gzip
26
+
27
+ _METADATA_STRING_MAPPING = {
28
+ NoCompression: 'identity',
29
+ Deflate: 'deflate',
30
+ Gzip: 'gzip',
31
+ }
32
+
33
+
34
+ def _compression_algorithm_to_metadata_value(
35
+ compression: grpc.Compression) -> str:
36
+ return _METADATA_STRING_MAPPING[compression]
37
+
38
+
39
+ def compression_algorithm_to_metadata(compression: grpc.Compression):
40
+ return (cygrpc.GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY,
41
+ _compression_algorithm_to_metadata_value(compression))
42
+
43
+
44
+ def create_channel_option(compression: Optional[grpc.Compression]):
45
+ return ((cygrpc.GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM,
46
+ int(compression)),) if compression else ()
47
+
48
+
49
+ def augment_metadata(metadata: Optional[MetadataType],
50
+ compression: Optional[grpc.Compression]):
51
+ if not metadata and not compression:
52
+ return None
53
+ base_metadata = tuple(metadata) if metadata else ()
54
+ compression_metadata = (
55
+ compression_algorithm_to_metadata(compression),) if compression else ()
56
+ return base_metadata + compression_metadata
57
+
58
+
59
+ __all__ = (
60
+ "NoCompression",
61
+ "Deflate",
62
+ "Gzip",
63
+ )
@@ -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.