14 """Abstract base classes for client-side Call objects.
16 Call objects represents the RPC itself, and offer methods to access / modify
17 its information. They also offer methods to manipulate the life-cycle of the
18 RPC, e.g. cancellation.
21 from abc
import ABCMeta
22 from abc
import abstractmethod
23 from typing
import AsyncIterable, Awaitable, Generic, Optional, Union
27 from ._metadata
import Metadata
28 from ._typing
import DoneCallbackType
29 from ._typing
import EOFType
30 from ._typing
import RequestType
31 from ._typing
import ResponseType
33 __all__ =
'RpcContext',
'Call',
'UnaryUnaryCall',
'UnaryStreamCall'
37 """Provides RPC-related information and action."""
41 """Return True if the RPC is cancelled.
43 The RPC is cancelled when the cancellation was requested with cancel().
46 A bool indicates whether the RPC is cancelled or not.
51 """Return True if the RPC is done.
53 An RPC is done if the RPC is completed, cancelled or aborted.
56 A bool indicates if the RPC is done.
61 """Describes the length of allowed time remaining for the RPC.
64 A nonnegative float indicating the length of allowed time in seconds
65 remaining for the RPC to complete before it is considered to have
66 timed out, or None if no deadline was specified for the RPC.
73 Idempotent and has no effect if the RPC has already terminated.
76 A bool indicates if the cancellation is performed or not.
81 """Registers a callback to be called on RPC termination.
84 callback: A callable object will be called with the call object as
90 """The abstract base class of an RPC on the client-side."""
94 """Accesses the initial metadata sent by the server.
97 The initial :term:`metadata`.
102 """Accesses the trailing metadata sent by the server.
105 The trailing :term:`metadata`.
109 async
def code(self) -> grpc.StatusCode:
110 """Accesses the status code sent by the server.
113 The StatusCode value for the RPC.
118 """Accesses the details sent by the server.
121 The details string of the RPC.
126 """Waits until connected to peer and raises aio.AioRpcError if failed.
128 This is an EXPERIMENTAL method.
130 This method ensures the RPC has been successfully connected. Otherwise,
131 an AioRpcError will be raised to explain the reason of the connection
134 This method is recommended for building retry mechanisms.
138 class UnaryUnaryCall(Generic[RequestType, ResponseType],
141 """The abstract base class of an unary-unary RPC on the client-side."""
145 """Await the response message to be ready.
148 The response message of the RPC.
158 """Returns the async iterable representation that yields messages.
160 Under the hood, it is calling the "read" method.
163 An async iterable object that yields messages.
167 async
def read(self) -> Union[EOFType, ResponseType]:
168 """Reads one message from the stream.
170 Read operations must be serialized when called from multiple
174 A response message, or an `grpc.aio.EOF` to indicate the end of the
184 async
def write(self, request: RequestType) ->
None:
185 """Writes one message to the stream.
188 An RpcError exception if the write failed.
193 """Notifies server that the client is done sending messages.
195 After done_writing is called, any additional invocation to the write
196 function will fail. This function is idempotent.
201 """Await the response message to be ready.
204 The response message of the stream.
214 """Returns the async iterable representation that yields messages.
216 Under the hood, it is calling the "read" method.
219 An async iterable object that yields messages.
223 async
def read(self) -> Union[EOFType, ResponseType]:
224 """Reads one message from the stream.
226 Read operations must be serialized when called from multiple
230 A response message, or an `grpc.aio.EOF` to indicate the end of the
235 async
def write(self, request: RequestType) ->
None:
236 """Writes one message to the stream.
239 An RpcError exception if the write failed.
244 """Notifies server that the client is done sending messages.
246 After done_writing is called, any additional invocation to the write
247 function will fail. This function is idempotent.