| 1 |
gRPC AsyncIO API |
| 2 |
================ |
| 3 |
|
| 4 |
.. module:: grpc.aio |
| 5 |
|
| 6 |
Overview |
| 7 |
-------- |
| 8 |
|
| 9 |
gRPC AsyncIO API is the **new version** of gRPC Python whose architecture is |
| 10 |
tailored to AsyncIO. Underlying, it utilizes the same C-extension, gRPC C-Core, |
| 11 |
as existing stack, and it replaces all gRPC IO operations with methods provided |
| 12 |
by the AsyncIO library. |
| 13 |
|
| 14 |
This API is stable. Feel free to open issues on our GitHub repo |
| 15 |
`grpc/grpc <https://github.com/grpc/grpc>`_ for bugs or suggestions. |
| 16 |
|
| 17 |
The design doc can be found here as `gRFC <https://github.com/grpc/proposal/pull/155>`_. |
| 18 |
|
| 19 |
|
| 20 |
Caveats |
| 21 |
------- |
| 22 |
|
| 23 |
gRPC Async API objects may only be used on the thread on which they were |
| 24 |
created. AsyncIO doesn't provide thread safety for most of its APIs. |
| 25 |
|
| 26 |
|
| 27 |
Blocking Code in AsyncIO |
| 28 |
------------------------ |
| 29 |
|
| 30 |
Making blocking function calls in coroutines or in the thread running event |
| 31 |
loop will block the event loop, potentially starving all RPCs in the process. |
| 32 |
Refer to the Python language documentation on AsyncIO for more details (`running-blocking-code <https://docs.python.org/3/library/asyncio-dev.html#running-blocking-code>`_). |
| 33 |
|
| 34 |
|
| 35 |
Module Contents |
| 36 |
--------------- |
| 37 |
|
| 38 |
|
| 39 |
Create Channel |
| 40 |
^^^^^^^^^^^^^^ |
| 41 |
|
| 42 |
Channels are the abstraction of clients, where most of networking logic |
| 43 |
happens, for example, managing one or more underlying connections, name |
| 44 |
resolution, load balancing, flow control, etc.. If you are using ProtoBuf, |
| 45 |
Channel objects works best when further encapsulate into stub objects, then the |
| 46 |
application can invoke remote functions as if they are local functions. |
| 47 |
|
| 48 |
.. autofunction:: insecure_channel |
| 49 |
.. autofunction:: secure_channel |
| 50 |
|
| 51 |
|
| 52 |
Channel Object |
| 53 |
^^^^^^^^^^^^^^ |
| 54 |
|
| 55 |
.. autoclass:: Channel |
| 56 |
|
| 57 |
|
| 58 |
Create Server |
| 59 |
^^^^^^^^^^^^^ |
| 60 |
|
| 61 |
.. autofunction:: server |
| 62 |
|
| 63 |
|
| 64 |
Server Object |
| 65 |
^^^^^^^^^^^^^ |
| 66 |
|
| 67 |
.. autoclass:: Server |
| 68 |
|
| 69 |
|
| 70 |
gRPC Exceptions |
| 71 |
^^^^^^^^^^^^^^^ |
| 72 |
|
| 73 |
.. autoexception:: BaseError |
| 74 |
.. autoexception:: UsageError |
| 75 |
.. autoexception:: AbortError |
| 76 |
.. autoexception:: InternalError |
| 77 |
.. autoexception:: AioRpcError |
| 78 |
|
| 79 |
gRPC Metadata |
| 80 |
^^^^^^^^^^^^^ |
| 81 |
|
| 82 |
.. autoclass:: Metadata |
| 83 |
|
| 84 |
|
| 85 |
Shared Context |
| 86 |
^^^^^^^^^^^^^^^^^^^^ |
| 87 |
|
| 88 |
.. autoclass:: RpcContext |
| 89 |
|
| 90 |
|
| 91 |
Client-Side Context |
| 92 |
^^^^^^^^^^^^^^^^^^^^^^^ |
| 93 |
|
| 94 |
.. autoclass:: Call |
| 95 |
.. autoclass:: UnaryUnaryCall |
| 96 |
.. autoclass:: UnaryStreamCall |
| 97 |
.. autoclass:: StreamUnaryCall |
| 98 |
.. autoclass:: StreamStreamCall |
| 99 |
|
| 100 |
|
| 101 |
Server-Side Context |
| 102 |
^^^^^^^^^^^^^^^^^^^^^^^ |
| 103 |
|
| 104 |
.. autoclass:: ServicerContext |
| 105 |
|
| 106 |
|
| 107 |
Client-Side Interceptor |
| 108 |
^^^^^^^^^^^^^^^^^^^^^^^ |
| 109 |
|
| 110 |
.. autoclass:: ClientCallDetails |
| 111 |
.. autoclass:: InterceptedUnaryUnaryCall |
| 112 |
.. autoclass:: ClientInterceptor |
| 113 |
.. autoclass:: UnaryUnaryClientInterceptor |
| 114 |
.. autoclass:: UnaryStreamClientInterceptor |
| 115 |
.. autoclass:: StreamUnaryClientInterceptor |
| 116 |
.. autoclass:: StreamStreamClientInterceptor |
| 117 |
|
| 118 |
Server-Side Interceptor |
| 119 |
^^^^^^^^^^^^^^^^^^^^^^^ |
| 120 |
|
| 121 |
.. autoclass:: ServerInterceptor |
| 122 |
|
| 123 |
|
| 124 |
Multi-Callable Interfaces |
| 125 |
^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 126 |
|
| 127 |
.. autoclass:: UnaryUnaryMultiCallable |
| 128 |
.. autoclass:: UnaryStreamMultiCallable() |
| 129 |
.. autoclass:: StreamUnaryMultiCallable() |
| 130 |
.. autoclass:: StreamStreamMultiCallable() |