asio-grpc v3.4.3
Asynchronous gRPC with Asio/unified executors
|
I/O object for server-side, server-streaming rpcs. More...
#include <agrpc/server_callback.hpp>
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. | |
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:
Executor | The executor type. |
Per-Operation Cancellation
All. Cancellation will merely interrupt the act of waiting and does not cancel the underlying rpc.
|
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.
|
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
.
|
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, ...).
|
inline |
Write message.
Initiate the read of a message from the client. The argument must remain valid until the read completes (wait_for_write()
).
|
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, ...).
|
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.
|
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.
|
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, ...).
|
inlinenodiscardnoexceptinherited |
Get the executor.
Thread-safe