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
@@ -0,0 +1,1049 @@
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.
14
+ """Interfaces defining the Face layer of RPC Framework."""
15
+
16
+ import abc
17
+ import collections
18
+ import enum
19
+
20
+ # cardinality, style, abandonment, future, and stream are
21
+ # referenced from specification in this module.
22
+ from grpc.framework.common import cardinality # pylint: disable=unused-import
23
+ from grpc.framework.common import style # pylint: disable=unused-import
24
+ from grpc.framework.foundation import future # pylint: disable=unused-import
25
+ from grpc.framework.foundation import stream # pylint: disable=unused-import
26
+
27
+ # pylint: disable=too-many-arguments
28
+
29
+
30
+ class NoSuchMethodError(Exception):
31
+ """Raised by customer code to indicate an unrecognized method.
32
+
33
+ Attributes:
34
+ group: The group of the unrecognized method.
35
+ name: The name of the unrecognized method.
36
+ """
37
+
38
+ def __init__(self, group, method):
39
+ """Constructor.
40
+
41
+ Args:
42
+ group: The group identifier of the unrecognized RPC name.
43
+ method: The method identifier of the unrecognized RPC name.
44
+ """
45
+ super(NoSuchMethodError, self).__init__()
46
+ self.group = group
47
+ self.method = method
48
+
49
+ def __repr__(self):
50
+ return 'face.NoSuchMethodError(%s, %s)' % (
51
+ self.group,
52
+ self.method,
53
+ )
54
+
55
+
56
+ class Abortion(
57
+ collections.namedtuple('Abortion', (
58
+ 'kind',
59
+ 'initial_metadata',
60
+ 'terminal_metadata',
61
+ 'code',
62
+ 'details',
63
+ ))):
64
+ """A value describing RPC abortion.
65
+
66
+ Attributes:
67
+ kind: A Kind value identifying how the RPC failed.
68
+ initial_metadata: The initial metadata from the other side of the RPC or
69
+ None if no initial metadata value was received.
70
+ terminal_metadata: The terminal metadata from the other side of the RPC or
71
+ None if no terminal metadata value was received.
72
+ code: The code value from the other side of the RPC or None if no code value
73
+ was received.
74
+ details: The details value from the other side of the RPC or None if no
75
+ details value was received.
76
+ """
77
+
78
+ @enum.unique
79
+ class Kind(enum.Enum):
80
+ """Types of RPC abortion."""
81
+
82
+ CANCELLED = 'cancelled'
83
+ EXPIRED = 'expired'
84
+ LOCAL_SHUTDOWN = 'local shutdown'
85
+ REMOTE_SHUTDOWN = 'remote shutdown'
86
+ NETWORK_FAILURE = 'network failure'
87
+ LOCAL_FAILURE = 'local failure'
88
+ REMOTE_FAILURE = 'remote failure'
89
+
90
+
91
+ class AbortionError(Exception, metaclass=abc.ABCMeta):
92
+ """Common super type for exceptions indicating RPC abortion.
93
+
94
+ initial_metadata: The initial metadata from the other side of the RPC or
95
+ None if no initial metadata value was received.
96
+ terminal_metadata: The terminal metadata from the other side of the RPC or
97
+ None if no terminal metadata value was received.
98
+ code: The code value from the other side of the RPC or None if no code value
99
+ was received.
100
+ details: The details value from the other side of the RPC or None if no
101
+ details value was received.
102
+ """
103
+
104
+ def __init__(self, initial_metadata, terminal_metadata, code, details):
105
+ super(AbortionError, self).__init__()
106
+ self.initial_metadata = initial_metadata
107
+ self.terminal_metadata = terminal_metadata
108
+ self.code = code
109
+ self.details = details
110
+
111
+ def __str__(self):
112
+ return '%s(code=%s, details="%s")' % (self.__class__.__name__,
113
+ self.code, self.details)
114
+
115
+
116
+ class CancellationError(AbortionError):
117
+ """Indicates that an RPC has been cancelled."""
118
+
119
+
120
+ class ExpirationError(AbortionError):
121
+ """Indicates that an RPC has expired ("timed out")."""
122
+
123
+
124
+ class LocalShutdownError(AbortionError):
125
+ """Indicates that an RPC has terminated due to local shutdown of RPCs."""
126
+
127
+
128
+ class RemoteShutdownError(AbortionError):
129
+ """Indicates that an RPC has terminated due to remote shutdown of RPCs."""
130
+
131
+
132
+ class NetworkError(AbortionError):
133
+ """Indicates that some error occurred on the network."""
134
+
135
+
136
+ class LocalError(AbortionError):
137
+ """Indicates that an RPC has terminated due to a local defect."""
138
+
139
+
140
+ class RemoteError(AbortionError):
141
+ """Indicates that an RPC has terminated due to a remote defect."""
142
+
143
+
144
+ class RpcContext(abc.ABC):
145
+ """Provides RPC-related information and action."""
146
+
147
+ @abc.abstractmethod
148
+ def is_active(self):
149
+ """Describes whether the RPC is active or has terminated."""
150
+ raise NotImplementedError()
151
+
152
+ @abc.abstractmethod
153
+ def time_remaining(self):
154
+ """Describes the length of allowed time remaining for the RPC.
155
+
156
+ Returns:
157
+ A nonnegative float indicating the length of allowed time in seconds
158
+ remaining for the RPC to complete before it is considered to have timed
159
+ out.
160
+ """
161
+ raise NotImplementedError()
162
+
163
+ @abc.abstractmethod
164
+ def add_abortion_callback(self, abortion_callback):
165
+ """Registers a callback to be called if the RPC is aborted.
166
+
167
+ Args:
168
+ abortion_callback: A callable to be called and passed an Abortion value
169
+ in the event of RPC abortion.
170
+ """
171
+ raise NotImplementedError()
172
+
173
+ @abc.abstractmethod
174
+ def cancel(self):
175
+ """Cancels the RPC.
176
+
177
+ Idempotent and has no effect if the RPC has already terminated.
178
+ """
179
+ raise NotImplementedError()
180
+
181
+ @abc.abstractmethod
182
+ def protocol_context(self):
183
+ """Accesses a custom object specified by an implementation provider.
184
+
185
+ Returns:
186
+ A value specified by the provider of a Face interface implementation
187
+ affording custom state and behavior.
188
+ """
189
+ raise NotImplementedError()
190
+
191
+
192
+ class Call(RpcContext, metaclass=abc.ABCMeta):
193
+ """Invocation-side utility object for an RPC."""
194
+
195
+ @abc.abstractmethod
196
+ def initial_metadata(self):
197
+ """Accesses the initial metadata from the service-side of the RPC.
198
+
199
+ This method blocks until the value is available or is known not to have been
200
+ emitted from the service-side of the RPC.
201
+
202
+ Returns:
203
+ The initial metadata object emitted by the service-side of the RPC, or
204
+ None if there was no such value.
205
+ """
206
+ raise NotImplementedError()
207
+
208
+ @abc.abstractmethod
209
+ def terminal_metadata(self):
210
+ """Accesses the terminal metadata from the service-side of the RPC.
211
+
212
+ This method blocks until the value is available or is known not to have been
213
+ emitted from the service-side of the RPC.
214
+
215
+ Returns:
216
+ The terminal metadata object emitted by the service-side of the RPC, or
217
+ None if there was no such value.
218
+ """
219
+ raise NotImplementedError()
220
+
221
+ @abc.abstractmethod
222
+ def code(self):
223
+ """Accesses the code emitted by the service-side of the RPC.
224
+
225
+ This method blocks until the value is available or is known not to have been
226
+ emitted from the service-side of the RPC.
227
+
228
+ Returns:
229
+ The code object emitted by the service-side of the RPC, or None if there
230
+ was no such value.
231
+ """
232
+ raise NotImplementedError()
233
+
234
+ @abc.abstractmethod
235
+ def details(self):
236
+ """Accesses the details value emitted by the service-side of the RPC.
237
+
238
+ This method blocks until the value is available or is known not to have been
239
+ emitted from the service-side of the RPC.
240
+
241
+ Returns:
242
+ The details value emitted by the service-side of the RPC, or None if there
243
+ was no such value.
244
+ """
245
+ raise NotImplementedError()
246
+
247
+
248
+ class ServicerContext(RpcContext, metaclass=abc.ABCMeta):
249
+ """A context object passed to method implementations."""
250
+
251
+ @abc.abstractmethod
252
+ def invocation_metadata(self):
253
+ """Accesses the metadata from the invocation-side of the RPC.
254
+
255
+ This method blocks until the value is available or is known not to have been
256
+ emitted from the invocation-side of the RPC.
257
+
258
+ Returns:
259
+ The metadata object emitted by the invocation-side of the RPC, or None if
260
+ there was no such value.
261
+ """
262
+ raise NotImplementedError()
263
+
264
+ @abc.abstractmethod
265
+ def initial_metadata(self, initial_metadata):
266
+ """Accepts the service-side initial metadata value of the RPC.
267
+
268
+ This method need not be called by method implementations if they have no
269
+ service-side initial metadata to transmit.
270
+
271
+ Args:
272
+ initial_metadata: The service-side initial metadata value of the RPC to
273
+ be transmitted to the invocation side of the RPC.
274
+ """
275
+ raise NotImplementedError()
276
+
277
+ @abc.abstractmethod
278
+ def terminal_metadata(self, terminal_metadata):
279
+ """Accepts the service-side terminal metadata value of the RPC.
280
+
281
+ This method need not be called by method implementations if they have no
282
+ service-side terminal metadata to transmit.
283
+
284
+ Args:
285
+ terminal_metadata: The service-side terminal metadata value of the RPC to
286
+ be transmitted to the invocation side of the RPC.
287
+ """
288
+ raise NotImplementedError()
289
+
290
+ @abc.abstractmethod
291
+ def code(self, code):
292
+ """Accepts the service-side code of the RPC.
293
+
294
+ This method need not be called by method implementations if they have no
295
+ code to transmit.
296
+
297
+ Args:
298
+ code: The code of the RPC to be transmitted to the invocation side of the
299
+ RPC.
300
+ """
301
+ raise NotImplementedError()
302
+
303
+ @abc.abstractmethod
304
+ def details(self, details):
305
+ """Accepts the service-side details of the RPC.
306
+
307
+ This method need not be called by method implementations if they have no
308
+ service-side details to transmit.
309
+
310
+ Args:
311
+ details: The service-side details value of the RPC to be transmitted to
312
+ the invocation side of the RPC.
313
+ """
314
+ raise NotImplementedError()
315
+
316
+
317
+ class ResponseReceiver(abc.ABC):
318
+ """Invocation-side object used to accept the output of an RPC."""
319
+
320
+ @abc.abstractmethod
321
+ def initial_metadata(self, initial_metadata):
322
+ """Receives the initial metadata from the service-side of the RPC.
323
+
324
+ Args:
325
+ initial_metadata: The initial metadata object emitted from the
326
+ service-side of the RPC.
327
+ """
328
+ raise NotImplementedError()
329
+
330
+ @abc.abstractmethod
331
+ def response(self, response):
332
+ """Receives a response from the service-side of the RPC.
333
+
334
+ Args:
335
+ response: A response object emitted from the service-side of the RPC.
336
+ """
337
+ raise NotImplementedError()
338
+
339
+ @abc.abstractmethod
340
+ def complete(self, terminal_metadata, code, details):
341
+ """Receives the completion values emitted from the service-side of the RPC.
342
+
343
+ Args:
344
+ terminal_metadata: The terminal metadata object emitted from the
345
+ service-side of the RPC.
346
+ code: The code object emitted from the service-side of the RPC.
347
+ details: The details object emitted from the service-side of the RPC.
348
+ """
349
+ raise NotImplementedError()
350
+
351
+
352
+ class UnaryUnaryMultiCallable(abc.ABC):
353
+ """Affords invoking a unary-unary RPC in any call style."""
354
+
355
+ @abc.abstractmethod
356
+ def __call__(self,
357
+ request,
358
+ timeout,
359
+ metadata=None,
360
+ with_call=False,
361
+ protocol_options=None):
362
+ """Synchronously invokes the underlying RPC.
363
+
364
+ Args:
365
+ request: The request value for the RPC.
366
+ timeout: A duration of time in seconds to allow for the RPC.
367
+ metadata: A metadata value to be passed to the service-side of
368
+ the RPC.
369
+ with_call: Whether or not to include return a Call for the RPC in addition
370
+ to the response.
371
+ protocol_options: A value specified by the provider of a Face interface
372
+ implementation affording custom state and behavior.
373
+
374
+ Returns:
375
+ The response value for the RPC, and a Call for the RPC if with_call was
376
+ set to True at invocation.
377
+
378
+ Raises:
379
+ AbortionError: Indicating that the RPC was aborted.
380
+ """
381
+ raise NotImplementedError()
382
+
383
+ @abc.abstractmethod
384
+ def future(self, request, timeout, metadata=None, protocol_options=None):
385
+ """Asynchronously invokes the underlying RPC.
386
+
387
+ Args:
388
+ request: The request value for the RPC.
389
+ timeout: A duration of time in seconds to allow for the RPC.
390
+ metadata: A metadata value to be passed to the service-side of
391
+ the RPC.
392
+ protocol_options: A value specified by the provider of a Face interface
393
+ implementation affording custom state and behavior.
394
+
395
+ Returns:
396
+ An object that is both a Call for the RPC and a future.Future. In the
397
+ event of RPC completion, the return Future's result value will be the
398
+ response value of the RPC. In the event of RPC abortion, the returned
399
+ Future's exception value will be an AbortionError.
400
+ """
401
+ raise NotImplementedError()
402
+
403
+ @abc.abstractmethod
404
+ def event(self,
405
+ request,
406
+ receiver,
407
+ abortion_callback,
408
+ timeout,
409
+ metadata=None,
410
+ protocol_options=None):
411
+ """Asynchronously invokes the underlying RPC.
412
+
413
+ Args:
414
+ request: The request value for the RPC.
415
+ receiver: A ResponseReceiver to be passed the response data of the RPC.
416
+ abortion_callback: A callback to be called and passed an Abortion value
417
+ in the event of RPC abortion.
418
+ timeout: A duration of time in seconds to allow for the RPC.
419
+ metadata: A metadata value to be passed to the service-side of
420
+ the RPC.
421
+ protocol_options: A value specified by the provider of a Face interface
422
+ implementation affording custom state and behavior.
423
+
424
+ Returns:
425
+ A Call for the RPC.
426
+ """
427
+ raise NotImplementedError()
428
+
429
+
430
+ class UnaryStreamMultiCallable(abc.ABC):
431
+ """Affords invoking a unary-stream RPC in any call style."""
432
+
433
+ @abc.abstractmethod
434
+ def __call__(self, request, timeout, metadata=None, protocol_options=None):
435
+ """Invokes the underlying RPC.
436
+
437
+ Args:
438
+ request: The request value for the RPC.
439
+ timeout: A duration of time in seconds to allow for the RPC.
440
+ metadata: A metadata value to be passed to the service-side of
441
+ the RPC.
442
+ protocol_options: A value specified by the provider of a Face interface
443
+ implementation affording custom state and behavior.
444
+
445
+ Returns:
446
+ An object that is both a Call for the RPC and an iterator of response
447
+ values. Drawing response values from the returned iterator may raise
448
+ AbortionError indicating abortion of the RPC.
449
+ """
450
+ raise NotImplementedError()
451
+
452
+ @abc.abstractmethod
453
+ def event(self,
454
+ request,
455
+ receiver,
456
+ abortion_callback,
457
+ timeout,
458
+ metadata=None,
459
+ protocol_options=None):
460
+ """Asynchronously invokes the underlying RPC.
461
+
462
+ Args:
463
+ request: The request value for the RPC.
464
+ receiver: A ResponseReceiver to be passed the response data of the RPC.
465
+ abortion_callback: A callback to be called and passed an Abortion value
466
+ in the event of RPC abortion.
467
+ timeout: A duration of time in seconds to allow for the RPC.
468
+ metadata: A metadata value to be passed to the service-side of
469
+ the RPC.
470
+ protocol_options: A value specified by the provider of a Face interface
471
+ implementation affording custom state and behavior.
472
+
473
+ Returns:
474
+ A Call object for the RPC.
475
+ """
476
+ raise NotImplementedError()
477
+
478
+
479
+ class StreamUnaryMultiCallable(abc.ABC):
480
+ """Affords invoking a stream-unary RPC in any call style."""
481
+
482
+ @abc.abstractmethod
483
+ def __call__(self,
484
+ request_iterator,
485
+ timeout,
486
+ metadata=None,
487
+ with_call=False,
488
+ protocol_options=None):
489
+ """Synchronously invokes the underlying RPC.
490
+
491
+ Args:
492
+ request_iterator: An iterator that yields request values for the RPC.
493
+ timeout: A duration of time in seconds to allow for the RPC.
494
+ metadata: A metadata value to be passed to the service-side of
495
+ the RPC.
496
+ with_call: Whether or not to include return a Call for the RPC in addition
497
+ to the response.
498
+ protocol_options: A value specified by the provider of a Face interface
499
+ implementation affording custom state and behavior.
500
+
501
+ Returns:
502
+ The response value for the RPC, and a Call for the RPC if with_call was
503
+ set to True at invocation.
504
+
505
+ Raises:
506
+ AbortionError: Indicating that the RPC was aborted.
507
+ """
508
+ raise NotImplementedError()
509
+
510
+ @abc.abstractmethod
511
+ def future(self,
512
+ request_iterator,
513
+ timeout,
514
+ metadata=None,
515
+ protocol_options=None):
516
+ """Asynchronously invokes the underlying RPC.
517
+
518
+ Args:
519
+ request_iterator: An iterator that yields request values for the RPC.
520
+ timeout: A duration of time in seconds to allow for the RPC.
521
+ metadata: A metadata value to be passed to the service-side of
522
+ the RPC.
523
+ protocol_options: A value specified by the provider of a Face interface
524
+ implementation affording custom state and behavior.
525
+
526
+ Returns:
527
+ An object that is both a Call for the RPC and a future.Future. In the
528
+ event of RPC completion, the return Future's result value will be the
529
+ response value of the RPC. In the event of RPC abortion, the returned
530
+ Future's exception value will be an AbortionError.
531
+ """
532
+ raise NotImplementedError()
533
+
534
+ @abc.abstractmethod
535
+ def event(self,
536
+ receiver,
537
+ abortion_callback,
538
+ timeout,
539
+ metadata=None,
540
+ protocol_options=None):
541
+ """Asynchronously invokes the underlying RPC.
542
+
543
+ Args:
544
+ receiver: A ResponseReceiver to be passed the response data of the RPC.
545
+ abortion_callback: A callback to be called and passed an Abortion value
546
+ in the event of RPC abortion.
547
+ timeout: A duration of time in seconds to allow for the RPC.
548
+ metadata: A metadata value to be passed to the service-side of
549
+ the RPC.
550
+ protocol_options: A value specified by the provider of a Face interface
551
+ implementation affording custom state and behavior.
552
+
553
+ Returns:
554
+ A single object that is both a Call object for the RPC and a
555
+ stream.Consumer to which the request values of the RPC should be passed.
556
+ """
557
+ raise NotImplementedError()
558
+
559
+
560
+ class StreamStreamMultiCallable(abc.ABC):
561
+ """Affords invoking a stream-stream RPC in any call style."""
562
+
563
+ @abc.abstractmethod
564
+ def __call__(self,
565
+ request_iterator,
566
+ timeout,
567
+ metadata=None,
568
+ protocol_options=None):
569
+ """Invokes the underlying RPC.
570
+
571
+ Args:
572
+ request_iterator: An iterator that yields request values for the RPC.
573
+ timeout: A duration of time in seconds to allow for the RPC.
574
+ metadata: A metadata value to be passed to the service-side of
575
+ the RPC.
576
+ protocol_options: A value specified by the provider of a Face interface
577
+ implementation affording custom state and behavior.
578
+
579
+ Returns:
580
+ An object that is both a Call for the RPC and an iterator of response
581
+ values. Drawing response values from the returned iterator may raise
582
+ AbortionError indicating abortion of the RPC.
583
+ """
584
+ raise NotImplementedError()
585
+
586
+ @abc.abstractmethod
587
+ def event(self,
588
+ receiver,
589
+ abortion_callback,
590
+ timeout,
591
+ metadata=None,
592
+ protocol_options=None):
593
+ """Asynchronously invokes the underlying RPC.
594
+
595
+ Args:
596
+ receiver: A ResponseReceiver to be passed the response data of the RPC.
597
+ abortion_callback: A callback to be called and passed an Abortion value
598
+ in the event of RPC abortion.
599
+ timeout: A duration of time in seconds to allow for the RPC.
600
+ metadata: A metadata value to be passed to the service-side of
601
+ the RPC.
602
+ protocol_options: A value specified by the provider of a Face interface
603
+ implementation affording custom state and behavior.
604
+
605
+ Returns:
606
+ A single object that is both a Call object for the RPC and a
607
+ stream.Consumer to which the request values of the RPC should be passed.
608
+ """
609
+ raise NotImplementedError()
610
+
611
+
612
+ class MethodImplementation(abc.ABC):
613
+ """A sum type that describes a method implementation.
614
+
615
+ Attributes:
616
+ cardinality: A cardinality.Cardinality value.
617
+ style: A style.Service value.
618
+ unary_unary_inline: The implementation of the method as a callable value
619
+ that takes a request value and a ServicerContext object and returns a
620
+ response value. Only non-None if cardinality is
621
+ cardinality.Cardinality.UNARY_UNARY and style is style.Service.INLINE.
622
+ unary_stream_inline: The implementation of the method as a callable value
623
+ that takes a request value and a ServicerContext object and returns an
624
+ iterator of response values. Only non-None if cardinality is
625
+ cardinality.Cardinality.UNARY_STREAM and style is style.Service.INLINE.
626
+ stream_unary_inline: The implementation of the method as a callable value
627
+ that takes an iterator of request values and a ServicerContext object and
628
+ returns a response value. Only non-None if cardinality is
629
+ cardinality.Cardinality.STREAM_UNARY and style is style.Service.INLINE.
630
+ stream_stream_inline: The implementation of the method as a callable value
631
+ that takes an iterator of request values and a ServicerContext object and
632
+ returns an iterator of response values. Only non-None if cardinality is
633
+ cardinality.Cardinality.STREAM_STREAM and style is style.Service.INLINE.
634
+ unary_unary_event: The implementation of the method as a callable value that
635
+ takes a request value, a response callback to which to pass the response
636
+ value of the RPC, and a ServicerContext. Only non-None if cardinality is
637
+ cardinality.Cardinality.UNARY_UNARY and style is style.Service.EVENT.
638
+ unary_stream_event: The implementation of the method as a callable value
639
+ that takes a request value, a stream.Consumer to which to pass the
640
+ response values of the RPC, and a ServicerContext. Only non-None if
641
+ cardinality is cardinality.Cardinality.UNARY_STREAM and style is
642
+ style.Service.EVENT.
643
+ stream_unary_event: The implementation of the method as a callable value
644
+ that takes a response callback to which to pass the response value of the
645
+ RPC and a ServicerContext and returns a stream.Consumer to which the
646
+ request values of the RPC should be passed. Only non-None if cardinality
647
+ is cardinality.Cardinality.STREAM_UNARY and style is style.Service.EVENT.
648
+ stream_stream_event: The implementation of the method as a callable value
649
+ that takes a stream.Consumer to which to pass the response values of the
650
+ RPC and a ServicerContext and returns a stream.Consumer to which the
651
+ request values of the RPC should be passed. Only non-None if cardinality
652
+ is cardinality.Cardinality.STREAM_STREAM and style is
653
+ style.Service.EVENT.
654
+ """
655
+
656
+
657
+ class MultiMethodImplementation(abc.ABC):
658
+ """A general type able to service many methods."""
659
+
660
+ @abc.abstractmethod
661
+ def service(self, group, method, response_consumer, context):
662
+ """Services an RPC.
663
+
664
+ Args:
665
+ group: The group identifier of the RPC.
666
+ method: The method identifier of the RPC.
667
+ response_consumer: A stream.Consumer to be called to accept the response
668
+ values of the RPC.
669
+ context: a ServicerContext object.
670
+
671
+ Returns:
672
+ A stream.Consumer with which to accept the request values of the RPC. The
673
+ consumer returned from this method may or may not be invoked to
674
+ completion: in the case of RPC abortion, RPC Framework will simply stop
675
+ passing values to this object. Implementations must not assume that this
676
+ object will be called to completion of the request stream or even called
677
+ at all.
678
+
679
+ Raises:
680
+ abandonment.Abandoned: May or may not be raised when the RPC has been
681
+ aborted.
682
+ NoSuchMethodError: If this MultiMethod does not recognize the given group
683
+ and name for the RPC and is not able to service the RPC.
684
+ """
685
+ raise NotImplementedError()
686
+
687
+
688
+ class GenericStub(abc.ABC):
689
+ """Affords RPC invocation via generic methods."""
690
+
691
+ @abc.abstractmethod
692
+ def blocking_unary_unary(self,
693
+ group,
694
+ method,
695
+ request,
696
+ timeout,
697
+ metadata=None,
698
+ with_call=False,
699
+ protocol_options=None):
700
+ """Invokes a unary-request-unary-response method.
701
+
702
+ This method blocks until either returning the response value of the RPC
703
+ (in the event of RPC completion) or raising an exception (in the event of
704
+ RPC abortion).
705
+
706
+ Args:
707
+ group: The group identifier of the RPC.
708
+ method: The method identifier of the RPC.
709
+ request: The request value for the RPC.
710
+ timeout: A duration of time in seconds to allow for the RPC.
711
+ metadata: A metadata value to be passed to the service-side of the RPC.
712
+ with_call: Whether or not to include return a Call for the RPC in addition
713
+ to the response.
714
+ protocol_options: A value specified by the provider of a Face interface
715
+ implementation affording custom state and behavior.
716
+
717
+ Returns:
718
+ The response value for the RPC, and a Call for the RPC if with_call was
719
+ set to True at invocation.
720
+
721
+ Raises:
722
+ AbortionError: Indicating that the RPC was aborted.
723
+ """
724
+ raise NotImplementedError()
725
+
726
+ @abc.abstractmethod
727
+ def future_unary_unary(self,
728
+ group,
729
+ method,
730
+ request,
731
+ timeout,
732
+ metadata=None,
733
+ protocol_options=None):
734
+ """Invokes a unary-request-unary-response method.
735
+
736
+ Args:
737
+ group: The group identifier of the RPC.
738
+ method: The method identifier of the RPC.
739
+ request: The request value for the RPC.
740
+ timeout: A duration of time in seconds to allow for the RPC.
741
+ metadata: A metadata value to be passed to the service-side of the RPC.
742
+ protocol_options: A value specified by the provider of a Face interface
743
+ implementation affording custom state and behavior.
744
+
745
+ Returns:
746
+ An object that is both a Call for the RPC and a future.Future. In the
747
+ event of RPC completion, the return Future's result value will be the
748
+ response value of the RPC. In the event of RPC abortion, the returned
749
+ Future's exception value will be an AbortionError.
750
+ """
751
+ raise NotImplementedError()
752
+
753
+ @abc.abstractmethod
754
+ def inline_unary_stream(self,
755
+ group,
756
+ method,
757
+ request,
758
+ timeout,
759
+ metadata=None,
760
+ protocol_options=None):
761
+ """Invokes a unary-request-stream-response method.
762
+
763
+ Args:
764
+ group: The group identifier of the RPC.
765
+ method: The method identifier of the RPC.
766
+ request: The request value for the RPC.
767
+ timeout: A duration of time in seconds to allow for the RPC.
768
+ metadata: A metadata value to be passed to the service-side of the RPC.
769
+ protocol_options: A value specified by the provider of a Face interface
770
+ implementation affording custom state and behavior.
771
+
772
+ Returns:
773
+ An object that is both a Call for the RPC and an iterator of response
774
+ values. Drawing response values from the returned iterator may raise
775
+ AbortionError indicating abortion of the RPC.
776
+ """
777
+ raise NotImplementedError()
778
+
779
+ @abc.abstractmethod
780
+ def blocking_stream_unary(self,
781
+ group,
782
+ method,
783
+ request_iterator,
784
+ timeout,
785
+ metadata=None,
786
+ with_call=False,
787
+ protocol_options=None):
788
+ """Invokes a stream-request-unary-response method.
789
+
790
+ This method blocks until either returning the response value of the RPC
791
+ (in the event of RPC completion) or raising an exception (in the event of
792
+ RPC abortion).
793
+
794
+ Args:
795
+ group: The group identifier of the RPC.
796
+ method: The method identifier of the RPC.
797
+ request_iterator: An iterator that yields request values for the RPC.
798
+ timeout: A duration of time in seconds to allow for the RPC.
799
+ metadata: A metadata value to be passed to the service-side of the RPC.
800
+ with_call: Whether or not to include return a Call for the RPC in addition
801
+ to the response.
802
+ protocol_options: A value specified by the provider of a Face interface
803
+ implementation affording custom state and behavior.
804
+
805
+ Returns:
806
+ The response value for the RPC, and a Call for the RPC if with_call was
807
+ set to True at invocation.
808
+
809
+ Raises:
810
+ AbortionError: Indicating that the RPC was aborted.
811
+ """
812
+ raise NotImplementedError()
813
+
814
+ @abc.abstractmethod
815
+ def future_stream_unary(self,
816
+ group,
817
+ method,
818
+ request_iterator,
819
+ timeout,
820
+ metadata=None,
821
+ protocol_options=None):
822
+ """Invokes a stream-request-unary-response method.
823
+
824
+ Args:
825
+ group: The group identifier of the RPC.
826
+ method: The method identifier of the RPC.
827
+ request_iterator: An iterator that yields request values for the RPC.
828
+ timeout: A duration of time in seconds to allow for the RPC.
829
+ metadata: A metadata value to be passed to the service-side of the RPC.
830
+ protocol_options: A value specified by the provider of a Face interface
831
+ implementation affording custom state and behavior.
832
+
833
+ Returns:
834
+ An object that is both a Call for the RPC and a future.Future. In the
835
+ event of RPC completion, the return Future's result value will be the
836
+ response value of the RPC. In the event of RPC abortion, the returned
837
+ Future's exception value will be an AbortionError.
838
+ """
839
+ raise NotImplementedError()
840
+
841
+ @abc.abstractmethod
842
+ def inline_stream_stream(self,
843
+ group,
844
+ method,
845
+ request_iterator,
846
+ timeout,
847
+ metadata=None,
848
+ protocol_options=None):
849
+ """Invokes a stream-request-stream-response method.
850
+
851
+ Args:
852
+ group: The group identifier of the RPC.
853
+ method: The method identifier of the RPC.
854
+ request_iterator: An iterator that yields request values for the RPC.
855
+ timeout: A duration of time in seconds to allow for the RPC.
856
+ metadata: A metadata value to be passed to the service-side of the RPC.
857
+ protocol_options: A value specified by the provider of a Face interface
858
+ implementation affording custom state and behavior.
859
+
860
+ Returns:
861
+ An object that is both a Call for the RPC and an iterator of response
862
+ values. Drawing response values from the returned iterator may raise
863
+ AbortionError indicating abortion of the RPC.
864
+ """
865
+ raise NotImplementedError()
866
+
867
+ @abc.abstractmethod
868
+ def event_unary_unary(self,
869
+ group,
870
+ method,
871
+ request,
872
+ receiver,
873
+ abortion_callback,
874
+ timeout,
875
+ metadata=None,
876
+ protocol_options=None):
877
+ """Event-driven invocation of a unary-request-unary-response method.
878
+
879
+ Args:
880
+ group: The group identifier of the RPC.
881
+ method: The method identifier of the RPC.
882
+ request: The request value for the RPC.
883
+ receiver: A ResponseReceiver to be passed the response data of the RPC.
884
+ abortion_callback: A callback to be called and passed an Abortion value
885
+ in the event of RPC abortion.
886
+ timeout: A duration of time in seconds to allow for the RPC.
887
+ metadata: A metadata value to be passed to the service-side of the RPC.
888
+ protocol_options: A value specified by the provider of a Face interface
889
+ implementation affording custom state and behavior.
890
+
891
+ Returns:
892
+ A Call for the RPC.
893
+ """
894
+ raise NotImplementedError()
895
+
896
+ @abc.abstractmethod
897
+ def event_unary_stream(self,
898
+ group,
899
+ method,
900
+ request,
901
+ receiver,
902
+ abortion_callback,
903
+ timeout,
904
+ metadata=None,
905
+ protocol_options=None):
906
+ """Event-driven invocation of a unary-request-stream-response method.
907
+
908
+ Args:
909
+ group: The group identifier of the RPC.
910
+ method: The method identifier of the RPC.
911
+ request: The request value for the RPC.
912
+ receiver: A ResponseReceiver to be passed the response data of the RPC.
913
+ abortion_callback: A callback to be called and passed an Abortion value
914
+ in the event of RPC abortion.
915
+ timeout: A duration of time in seconds to allow for the RPC.
916
+ metadata: A metadata value to be passed to the service-side of the RPC.
917
+ protocol_options: A value specified by the provider of a Face interface
918
+ implementation affording custom state and behavior.
919
+
920
+ Returns:
921
+ A Call for the RPC.
922
+ """
923
+ raise NotImplementedError()
924
+
925
+ @abc.abstractmethod
926
+ def event_stream_unary(self,
927
+ group,
928
+ method,
929
+ receiver,
930
+ abortion_callback,
931
+ timeout,
932
+ metadata=None,
933
+ protocol_options=None):
934
+ """Event-driven invocation of a unary-request-unary-response method.
935
+
936
+ Args:
937
+ group: The group identifier of the RPC.
938
+ method: The method identifier of the RPC.
939
+ receiver: A ResponseReceiver to be passed the response data of the RPC.
940
+ abortion_callback: A callback to be called and passed an Abortion value
941
+ in the event of RPC abortion.
942
+ timeout: A duration of time in seconds to allow for the RPC.
943
+ metadata: A metadata value to be passed to the service-side of the RPC.
944
+ protocol_options: A value specified by the provider of a Face interface
945
+ implementation affording custom state and behavior.
946
+
947
+ Returns:
948
+ A pair of a Call object for the RPC and a stream.Consumer to which the
949
+ request values of the RPC should be passed.
950
+ """
951
+ raise NotImplementedError()
952
+
953
+ @abc.abstractmethod
954
+ def event_stream_stream(self,
955
+ group,
956
+ method,
957
+ receiver,
958
+ abortion_callback,
959
+ timeout,
960
+ metadata=None,
961
+ protocol_options=None):
962
+ """Event-driven invocation of a unary-request-stream-response method.
963
+
964
+ Args:
965
+ group: The group identifier of the RPC.
966
+ method: The method identifier of the RPC.
967
+ receiver: A ResponseReceiver to be passed the response data of the RPC.
968
+ abortion_callback: A callback to be called and passed an Abortion value
969
+ in the event of RPC abortion.
970
+ timeout: A duration of time in seconds to allow for the RPC.
971
+ metadata: A metadata value to be passed to the service-side of the RPC.
972
+ protocol_options: A value specified by the provider of a Face interface
973
+ implementation affording custom state and behavior.
974
+
975
+ Returns:
976
+ A pair of a Call object for the RPC and a stream.Consumer to which the
977
+ request values of the RPC should be passed.
978
+ """
979
+ raise NotImplementedError()
980
+
981
+ @abc.abstractmethod
982
+ def unary_unary(self, group, method):
983
+ """Creates a UnaryUnaryMultiCallable for a unary-unary method.
984
+
985
+ Args:
986
+ group: The group identifier of the RPC.
987
+ method: The method identifier of the RPC.
988
+
989
+ Returns:
990
+ A UnaryUnaryMultiCallable value for the named unary-unary method.
991
+ """
992
+ raise NotImplementedError()
993
+
994
+ @abc.abstractmethod
995
+ def unary_stream(self, group, method):
996
+ """Creates a UnaryStreamMultiCallable for a unary-stream method.
997
+
998
+ Args:
999
+ group: The group identifier of the RPC.
1000
+ method: The method identifier of the RPC.
1001
+
1002
+ Returns:
1003
+ A UnaryStreamMultiCallable value for the name unary-stream method.
1004
+ """
1005
+ raise NotImplementedError()
1006
+
1007
+ @abc.abstractmethod
1008
+ def stream_unary(self, group, method):
1009
+ """Creates a StreamUnaryMultiCallable for a stream-unary method.
1010
+
1011
+ Args:
1012
+ group: The group identifier of the RPC.
1013
+ method: The method identifier of the RPC.
1014
+
1015
+ Returns:
1016
+ A StreamUnaryMultiCallable value for the named stream-unary method.
1017
+ """
1018
+ raise NotImplementedError()
1019
+
1020
+ @abc.abstractmethod
1021
+ def stream_stream(self, group, method):
1022
+ """Creates a StreamStreamMultiCallable for a stream-stream method.
1023
+
1024
+ Args:
1025
+ group: The group identifier of the RPC.
1026
+ method: The method identifier of the RPC.
1027
+
1028
+ Returns:
1029
+ A StreamStreamMultiCallable value for the named stream-stream method.
1030
+ """
1031
+ raise NotImplementedError()
1032
+
1033
+
1034
+ class DynamicStub(abc.ABC):
1035
+ """Affords RPC invocation via attributes corresponding to afforded methods.
1036
+
1037
+ Instances of this type may be scoped to a single group so that attribute
1038
+ access is unambiguous.
1039
+
1040
+ Instances of this type respond to attribute access as follows: if the
1041
+ requested attribute is the name of a unary-unary method, the value of the
1042
+ attribute will be a UnaryUnaryMultiCallable with which to invoke an RPC; if
1043
+ the requested attribute is the name of a unary-stream method, the value of the
1044
+ attribute will be a UnaryStreamMultiCallable with which to invoke an RPC; if
1045
+ the requested attribute is the name of a stream-unary method, the value of the
1046
+ attribute will be a StreamUnaryMultiCallable with which to invoke an RPC; and
1047
+ if the requested attribute is the name of a stream-stream method, the value of
1048
+ the attribute will be a StreamStreamMultiCallable with which to invoke an RPC.
1049
+ """