GRPC C++  1.62.0
Public Member Functions | Friends
grpc::ClientBidiReactor< Request, Response > Class Template Reference

ClientBidiReactor is the interface for a bidirectional streaming RPC. More...

#include <client_callback.h>

Public Member Functions

void StartCall ()
 Activate the RPC and initiate any reads or writes that have been Start'ed before this call. More...
 
void StartRead (Response *resp)
 Initiate a read operation (or post it for later initiation if StartCall has not yet been invoked). More...
 
void StartWrite (const Request *req)
 Initiate a write operation (or post it for later initiation if StartCall has not yet been invoked). More...
 
void StartWrite (const Request *req, grpc::WriteOptions options)
 Initiate/post a write operation with specified options. More...
 
void StartWriteLast (const Request *req, grpc::WriteOptions options)
 Initiate/post a write operation with specified options and an indication that this is the last write (like StartWrite and StartWritesDone, merged). More...
 
void StartWritesDone ()
 Indicate that the RPC will have no more write operations. More...
 
void AddHold ()
 Holds are needed if (and only if) this stream has operations that take place on it after StartCall but from outside one of the reactions (OnReadDone, etc). More...
 
void AddMultipleHolds (int holds)
 
void RemoveHold ()
 
void OnDone (const grpc::Status &) override
 Notifies the application that all operations associated with this RPC have completed and all Holds have been removed. More...
 
virtual void OnReadInitialMetadataDone (bool)
 Notifies the application that a read of initial metadata from the server is done. More...
 
virtual void OnReadDone (bool)
 Notifies the application that a StartRead operation completed. More...
 
virtual void OnWriteDone (bool)
 Notifies the application that a StartWrite or StartWriteLast operation completed. More...
 
virtual void OnWritesDoneDone (bool)
 Notifies the application that a StartWritesDone operation completed. More...
 

Friends

class ClientCallbackReaderWriter< Request, Response >
 

Detailed Description

template<class Request, class Response>
class grpc::ClientBidiReactor< Request, Response >

ClientBidiReactor is the interface for a bidirectional streaming RPC.

Member Function Documentation

◆ AddHold()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::AddHold ( )
inline

Holds are needed if (and only if) this stream has operations that take place on it after StartCall but from outside one of the reactions (OnReadDone, etc).

This is not a common use of the streaming API.

Holds must be added before calling StartCall. If a stream still has a hold in place, its resources will not be destroyed even if the status has already come in from the wire and there are currently no active callbacks outstanding. Similarly, the stream will not call OnDone if there are still holds on it.

For example, if a StartRead or StartWrite operation is going to be initiated from elsewhere in the application, the application should call AddHold or AddMultipleHolds before StartCall. If there is going to be, for example, a read-flow and a write-flow taking place outside the reactions, then call AddMultipleHolds(2) before StartCall. When the application knows that it won't issue any more read operations (such as when a read comes back as not ok), it should issue a RemoveHold(). It should also call RemoveHold() again after it does StartWriteLast or StartWritesDone that indicates that there will be no more write ops. The number of RemoveHold calls must match the total number of AddHold calls plus the number of holds added by AddMultipleHolds. The argument to AddMultipleHolds must be positive.

◆ AddMultipleHolds()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::AddMultipleHolds ( int  holds)
inline

◆ OnDone()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::OnDone ( const grpc::Status )
inlineoverride

Notifies the application that all operations associated with this RPC have completed and all Holds have been removed.

OnDone provides the RPC status outcome for both successful and failed RPCs and will be called in all cases. If it is not called, it indicates an application-level problem (like failure to remove a hold).

Parameters
[in]sThe status outcome of this RPC

◆ OnReadDone()

template<class Request , class Response >
virtual void grpc::ClientBidiReactor< Request, Response >::OnReadDone ( bool  )
inlinevirtual

Notifies the application that a StartRead operation completed.

Parameters
[in]okWas it successful? If false, no new read/write operation will succeed, and any further Start* should not be called.

◆ OnReadInitialMetadataDone()

template<class Request , class Response >
virtual void grpc::ClientBidiReactor< Request, Response >::OnReadInitialMetadataDone ( bool  )
inlinevirtual

Notifies the application that a read of initial metadata from the server is done.

If the application chooses not to implement this method, it can assume that the initial metadata has been read before the first call of OnReadDone or OnDone.

Parameters
[in]okWas the initial metadata read successfully? If false, no new read/write operation will succeed, and any further Start* operations should not be called.

◆ OnWriteDone()

template<class Request , class Response >
virtual void grpc::ClientBidiReactor< Request, Response >::OnWriteDone ( bool  )
inlinevirtual

Notifies the application that a StartWrite or StartWriteLast operation completed.

Parameters
[in]okWas it successful? If false, no new read/write operation will succeed, and any further Start* should not be called.

◆ OnWritesDoneDone()

template<class Request , class Response >
virtual void grpc::ClientBidiReactor< Request, Response >::OnWritesDoneDone ( bool  )
inlinevirtual

Notifies the application that a StartWritesDone operation completed.

Note that this is only used on explicit StartWritesDone operations and not for those that are implicitly invoked as part of a StartWriteLast.

Parameters
[in]okWas it successful? If false, the application will later see the failure reflected as a bad status in OnDone and no further Start* should be called.

◆ RemoveHold()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::RemoveHold ( )
inline

◆ StartCall()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::StartCall ( )
inline

Activate the RPC and initiate any reads or writes that have been Start'ed before this call.

All streaming RPCs issued by the client MUST have StartCall invoked on them (even if they are canceled) as this call is the activation of their lifecycle.

◆ StartRead()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::StartRead ( Response *  resp)
inline

Initiate a read operation (or post it for later initiation if StartCall has not yet been invoked).

Parameters
[out]respWhere to eventually store the read message. Valid when the library calls OnReadDone

◆ StartWrite() [1/2]

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::StartWrite ( const Request *  req)
inline

Initiate a write operation (or post it for later initiation if StartCall has not yet been invoked).

Parameters
[in]reqThe message to be written. The library does not take ownership but the caller must ensure that the message is not deleted or modified until OnWriteDone is called.

◆ StartWrite() [2/2]

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::StartWrite ( const Request *  req,
grpc::WriteOptions  options 
)
inline

Initiate/post a write operation with specified options.

Parameters
[in]reqThe message to be written. The library does not take ownership but the caller must ensure that the message is not deleted or modified until OnWriteDone is called.
[in]optionsThe WriteOptions to use for writing this message

◆ StartWriteLast()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::StartWriteLast ( const Request *  req,
grpc::WriteOptions  options 
)
inline

Initiate/post a write operation with specified options and an indication that this is the last write (like StartWrite and StartWritesDone, merged).

Note that calling this means that no more calls to StartWrite, StartWriteLast, or StartWritesDone are allowed.

Parameters
[in]reqThe message to be written. The library does not take ownership but the caller must ensure that the message is not deleted or modified until OnWriteDone is called.
[in]optionsThe WriteOptions to use for writing this message

◆ StartWritesDone()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::StartWritesDone ( )
inline

Indicate that the RPC will have no more write operations.

This can only be issued once for a given RPC. This is not required or allowed if StartWriteLast is used since that already has the same implication. Note that calling this means that no more calls to StartWrite, StartWriteLast, or StartWritesDone are allowed.

Friends And Related Function Documentation

◆ ClientCallbackReaderWriter< Request, Response >

template<class Request , class Response >
friend class ClientCallbackReaderWriter< Request, Response >
friend

The documentation for this class was generated from the following file: