asio-grpc v3.4.3
Asynchronous gRPC with Asio/unified executors
Loading...
Searching...
No Matches
agrpc::BasicServerWriteReactor< Response, Executor > Class Template Reference

I/O object for server-side, server-streaming rpcs. More...

#include <agrpc/server_callback.hpp>

+ Inheritance diagram for agrpc::BasicServerWriteReactor< Response, Executor >:
+ Collaboration diagram for agrpc::BasicServerWriteReactor< Response, Executor >:

Classes

struct  rebind_executor
 Rebind the BasicServerWriteReactor to another executor. More...
 

Public Types

using executor_type = Executor
 The executor type.
 

Public Member Functions

grpc::ServerWriteReactor< Response > * get () noexcept
 Get underlying gRPC reactor.
 
void initiate_send_initial_metadata ()
 Send initial metadata.
 
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>>
auto wait_for_send_initial_metadata (CompletionToken &&token=CompletionToken{})
 Wait for send initial metadata.
 
void initiate_write (const Response &response, grpc::WriteOptions options={})
 Write message.
 
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>>
auto wait_for_write (CompletionToken &&token=CompletionToken{})
 Wait for read.
 
void initiate_write_and_finish (const Response &response, grpc::Status status, grpc::WriteOptions options={})
 Write message and finish rpc.
 
void initiate_finish (grpc::Status status)
 Finish rpc.
 
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>>
auto wait_for_finish (CompletionToken &&token=CompletionToken{})
 Wait for finish.
 
const Executor & get_executor () const noexcept
 Get the executor.
 

Detailed Description

template<class Response, class Executor>
class agrpc::BasicServerWriteReactor< Response, Executor >

I/O object for server-side, server-streaming rpcs.

Create an object of this type using agrpc::make_reactor/agrpc::allocate_reactor or server_callback_coroutine.hpp.

Example:

Based on .proto file:

syntax = "proto3";
package example.v1;
service Example {
rpc ServerStreaming(Request) returns (stream Response) {}
rpc ClientStreaming(stream Request) returns (Response) {}
rpc BidirectionalStreaming(stream Request) returns (stream Response) {}
rpc Unary(Request) returns (Response) {}
}
message Request {
int32 integer = 1;
}
message Response {
int32 integer = 1;
}
Template Parameters
ExecutorThe executor type.

Per-Operation Cancellation

All. Cancellation will merely interrupt the act of waiting and does not cancel the underlying rpc.

Since
3.5.0

Member Function Documentation

◆ get()

template<class Response , class Executor >
grpc::ServerWriteReactor< Response > * agrpc::BasicServerWriteReactor< Response, Executor >::get ( )
inlinenodiscardnoexcept

Get underlying gRPC reactor.

The returned object should be passed to the gRPC library. Invoking any of its functions may result in undefined behavior.

◆ initiate_send_initial_metadata()

template<class Response , class Executor >
void agrpc::BasicServerWriteReactor< Response, Executor >::initiate_send_initial_metadata ( )
inline

Send initial metadata.

Send any initial metadata stored in the CallbackServerContext. If not invoked, any initial metadata will be passed along with initiate_finish.

◆ wait_for_send_initial_metadata()

template<class Response , class Executor >
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>>
auto agrpc::BasicServerWriteReactor< Response, Executor >::wait_for_send_initial_metadata ( CompletionToken && token = CompletionToken{})
inline

Wait for send initial metadata.

Waits for the completion of initiate_send_initial_metadata. Only one wait for send initial metadata may be outstanding at any time.

Completion signature is void(error_code, bool). If the bool is false then the rpc failed (cancelled, disconnected, deadline reached, ...).

◆ initiate_write()

template<class Response , class Executor >
void agrpc::BasicServerWriteReactor< Response, Executor >::initiate_write ( const Response & response,
grpc::WriteOptions options = {} )
inline

Write message.

Initiate the read of a message from the client. The argument must remain valid until the read completes (wait_for_write()).

◆ wait_for_write()

template<class Response , class Executor >
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>>
auto agrpc::BasicServerWriteReactor< Response, Executor >::wait_for_write ( CompletionToken && token = CompletionToken{})
inline

Wait for read.

Waits for the completion of a write. Only one wait for read may be outstanding at any time.

Completion signature is void(error_code, bool). If the bool is false then the rpc failed (cancelled, disconnected, deadline reached, ...).

◆ initiate_write_and_finish()

template<class Response , class Executor >
void agrpc::BasicServerWriteReactor< Response, Executor >::initiate_write_and_finish ( const Response & response,
grpc::Status status,
grpc::WriteOptions options = {} )
inline

Write message and finish rpc.

Initiate a write operation with specified options and final rpc status, which also causes any trailing metadata for this rpc to be sent out. The argument must remain valid until the rpc completes (wait_for_finish()). Either initiate_write_and_finish() or initiate_finish() may be called but not both.

◆ initiate_finish()

template<class Response , class Executor >
void agrpc::BasicServerWriteReactor< Response, Executor >::initiate_finish ( grpc::Status status)
inline

Finish rpc.

Indicate that the stream is to be finished and the trailing metadata and rpc status are to be sent. May only be called once. If the status is non-OK, any message will not be sent. Instead, the client will only receive the status and any trailing metadata. Either initiate_write_and_finish() or initiate_finish() may be called but not both.

◆ wait_for_finish()

template<class Response , class Executor >
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>>
auto agrpc::BasicServerWriteReactor< Response, Executor >::wait_for_finish ( CompletionToken && token = CompletionToken{})
inline

Wait for finish.

Wait until all operations associated with this rpc have completed. Only one wait for finish may be outstanding at any time.

Completion signature is void(error_code, bool). If the bool is false then the rpc failed (cancelled, disconnected, deadline reached, ...).

◆ get_executor()

template<class Executor >
const Executor & agrpc::detail::ReactorExecutorBase< Executor >::get_executor ( ) const
inlinenodiscardnoexceptinherited

Get the executor.

Thread-safe