A streaming read-write RPC.
Streaming read-write RPCs (sometimes called bidirectional streaming RPCs) allow applications to send multiple "requests" and receive multiple "responses" on the same request. They are often used in services where sending one request at a time introduces too much latency. The requests
Constructors
~AsyncStreamingReadWriteRpc
Functions
Cancel
Sends a best-effort request to cancel the RPC.
The application should still wait for the current operation(s) (any pending Start()
, Read()
, or Write*()
requests) to complete and use Finish()
to determine the status of the RPC.
Returns | |
---|---|
Type | Description |
void |
Start
Start the streaming RPC.
Applications should call Start()
and wait for its result before calling Read()
and/or Write()
. If Start()
completes with false
the stream has completed with an error. The application should not call Read()
or Write()
in this case. On errors, the application should callFinish()
to determine the status of the streaming RPC.
Returns | |
---|---|
Type | Description |
future< bool > |
Read
Read one response from the streaming RPC.
Note: Only one
Read()
operation may be pending at a time. The application is responsible for waiting until any previousRead()
operations have completed before callingRead()
again. WhetherRead()
can be called before aWrite()
operation is specified by each service and RPC. Most services require at least oneWrite()
call before callingRead()
. Many services may return more than one response for a singleWrite()
request. Each service and RPC specifies how to discover if more responses will be forthcoming.
If the optional<>
is not engaged the streaming RPC has completed. The application should wait until any other pending operations (typically any other Write()
calls) complete and then call Finish()
to find the status of the streaming RPC.
Returns | |
---|---|
Type | Description |
future< absl::optional< Response > > |
Write
Write one request to the streaming RPC.
Note: Only one
Write()
operation may be pending at a time. The application is responsible for waiting until any previousWrite()
operations have completed before callingWrite()
again. WhetherWrite()
can be called before waiting for a matchingRead()
operation is specified by each service and RPC. Many services tolerate multipleWrite()
calls before performing or at least receiving aRead()
response.
If Write()
completes with false
the streaming RPC has completed. The application should wait until any other pending operations (typically any other Read()
calls) complete and then call Finish()
to find the status of the streaming RPC.
Parameters | |
---|---|
Name | Description |
|
Request const &
|
|
grpc::WriteOptions
|
Returns | |
---|---|
Type | Description |
future< bool > |
WritesDone
Half-closes the streaming RPC.
Sends an indication to the service that no more requests will be issued by the client.
If WritesDone()
completes with false
the streaming RPC has completed. The application should wait until any other pending operations (typically any other Read()
calls) complete and then call Finish()
to find the status of the streaming RPC.
Returns | |
---|---|
Type | Description |
future< bool > |
Finish
Return the final status of the streaming RPC.
Streaming RPCs may return an error because the stream is closed, independently of any whether the application has called WritesDone()
or signaled that the stream is closed using other mechanisms (some RPCs define specific attributes to "close" the stream).
The application must wait until all pending Read()
and Write()
operations have completed before calling Finish()
.
Returns | |
---|---|
Type | Description |
future< Status > |