Google Cloud C++ Client  1.42.0
C++ Client Library for Google Cloud Platform
Public Member Functions | List of all members
google::cloud::AsyncStreamingReadWriteRpc< Request, Response > Class Template Referenceabstract

A streaming read-write RPC. More...

#include <google/cloud/async_streaming_read_write_rpc.h>

Public Member Functions

virtual ~AsyncStreamingReadWriteRpc ()=default
 
virtual void Cancel ()=0
 Sends a best-effort request to cancel the RPC. More...
 
virtual future< bool > Start ()=0
 Start the streaming RPC. More...
 
virtual future< absl::optional< Response > > Read ()=0
 Read one response from the streaming RPC. More...
 
virtual future< bool > Write (Request const &, grpc::WriteOptions)=0
 Write one request to the streaming RPC. More...
 
virtual future< bool > WritesDone ()=0
 Half-closes the streaming RPC. More...
 
virtual future< StatusFinish ()=0
 Return the final status of the streaming RPC. More...
 

Detailed Description

template<typename Request, typename Response>
class google::cloud::AsyncStreamingReadWriteRpc< Request, Response >

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

Definition at line 37 of file async_streaming_read_write_rpc.h.

Constructor & Destructor Documentation

◆ ~AsyncStreamingReadWriteRpc()

template<typename Request , typename Response >
virtual google::cloud::AsyncStreamingReadWriteRpc< Request, Response >::~AsyncStreamingReadWriteRpc ( )
virtualdefault

Member Function Documentation

◆ Cancel()

template<typename Request , typename Response >
virtual void google::cloud::AsyncStreamingReadWriteRpc< Request, Response >::Cancel ( )
pure virtual

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.

◆ Finish()

template<typename Request , typename Response >
virtual future<Status> google::cloud::AsyncStreamingReadWriteRpc< Request, Response >::Finish ( )
pure virtual

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().

◆ Read()

template<typename Request , typename Response >
virtual future<absl::optional<Response> > google::cloud::AsyncStreamingReadWriteRpc< Request, Response >::Read ( )
pure virtual

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 previous Read() operations have completed before calling Read() again.

Whether Read() can be called before a Write() operation is specified by each service and RPC. Most services require at least one Write() call before calling Read(). Many services may return more than one response for a single Write() 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.

◆ Start()

template<typename Request , typename Response >
virtual future<bool> google::cloud::AsyncStreamingReadWriteRpc< Request, Response >::Start ( )
pure virtual

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.

◆ Write()

template<typename Request , typename Response >
virtual future<bool> google::cloud::AsyncStreamingReadWriteRpc< Request, Response >::Write ( Request const &  ,
grpc::WriteOptions   
)
pure virtual

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 previous Write() operations have completed before calling Write() again.

Whether Write() can be called before waiting for a matching Read() operation is specified by each service and RPC. Many services tolerate multiple Write() calls before performing or at least receiving a Read() 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.

◆ WritesDone()

template<typename Request , typename Response >
virtual future<bool> google::cloud::AsyncStreamingReadWriteRpc< Request, Response >::WritesDone ( )
pure virtual

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.