grpc_asyncio.rst 2.9 KB

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