Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
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 AddHold ()
 
void AddMultipleHolds (int holds)
 
void OnDone (const grpc::Status &) override
 
virtual void OnReadDone (bool)
 
virtual void OnReadInitialMetadataDone (bool)
 
virtual void OnWriteDone (bool)
 
virtual void OnWritesDoneDone (bool)
 
void RemoveHold ()
 
void StartCall ()
 
void StartRead (Response *resp)
 
void StartWrite (const Request *req)
 
void StartWrite (const Request *req, grpc::WriteOptions options)
 
void StartWriteLast (const Request *req, grpc::WriteOptions options)
 
void StartWritesDone ()
 

Private Member Functions

void BindStream (ClientCallbackReaderWriter< Request, Response > *stream)
 

Private Attributes

ClientCallbackReaderWriter< Request, Response > * stream_
 

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.

Definition at line 151 of file impl/codegen/client_callback.h.

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.

Definition at line 315 of file impl/codegen/client_callback.h.

◆ AddMultipleHolds()

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

Definition at line 316 of file impl/codegen/client_callback.h.

◆ BindStream()

template<class Request , class Response >
void grpc::ClientBidiReactor< Request, Response >::BindStream ( ClientCallbackReaderWriter< Request, Response > *  stream)
inlineprivate

Definition at line 365 of file impl/codegen/client_callback.h.

◆ 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

Definition at line 329 of file impl/codegen/client_callback.h.

◆ 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.

Reimplemented in grpc::testing::CallbackStreamingPingPongReactor, and grpc::testing::BidiClient.

Definition at line 345 of file impl/codegen/client_callback.h.

◆ 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.

Definition at line 339 of file impl/codegen/client_callback.h.

◆ 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.

Reimplemented in grpc::testing::CallbackStreamingPingPongReactor, and grpc::testing::BidiClient.

Definition at line 352 of file impl/codegen/client_callback.h.

◆ 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.

Definition at line 361 of file impl/codegen/client_callback.h.

◆ RemoveHold()

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

Definition at line 320 of file impl/codegen/client_callback.h.

◆ 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.

Definition at line 246 of file impl/codegen/client_callback.h.

◆ 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

Definition at line 253 of file impl/codegen/client_callback.h.

◆ 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.

Definition at line 261 of file impl/codegen/client_callback.h.

◆ 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

Definition at line 269 of file impl/codegen/client_callback.h.

◆ 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

Definition at line 282 of file impl/codegen/client_callback.h.

◆ 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.

Definition at line 291 of file impl/codegen/client_callback.h.

Friends And Related Function Documentation

◆ ClientCallbackReaderWriter< Request, Response >

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

Definition at line 364 of file impl/codegen/client_callback.h.

Member Data Documentation

◆ stream_

template<class Request , class Response >
ClientCallbackReaderWriter<Request, Response>* grpc::ClientBidiReactor< Request, Response >::stream_
private

Definition at line 368 of file impl/codegen/client_callback.h.


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


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:30