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