asio-grpc v3.1.0
Asynchronous gRPC with Asio/unified executors
|
I/O object for client-side, client-streaming rpcs. More...
#include <agrpc/client_rpc.hpp>
Classes | |
struct | rebind_executor |
Rebind the ClientRPC to another executor. More... | |
Public Member Functions | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
auto | start (StubT &stub, ResponseT &response, CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Start a client-streaming request. More... | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
auto | read_initial_metadata (CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Read initial metadata. More... | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
auto | write (const RequestT &request, grpc::WriteOptions options, CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Send a message to the server. More... | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
auto | write (const RequestT &request, CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Send a message to the server. More... | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
auto | finish (CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Finish the rpc. More... | |
const executor_type & | get_executor () const noexcept |
Get the executor. More... | |
const executor_type & | get_scheduler () const noexcept |
Get the scheduler. More... | |
grpc::ClientContext & | context () |
Get the underlying grpc::ClientContext | |
const grpc::ClientContext & | context () const |
Get the underlying grpc::ClientContext (const overload) | |
void | cancel () noexcept |
Cancel this RPC. More... | |
Static Public Member Functions | |
static constexpr std::string_view | service_name () noexcept |
Name of the gRPC service. More... | |
static constexpr std::string_view | method_name () noexcept |
Name of the gRPC method. More... | |
Static Public Attributes | |
static constexpr agrpc::ClientRPCType | TYPE = agrpc::ClientRPCType::CLIENT_STREAMING |
The rpc type. | |
I/O object for client-side, client-streaming rpcs.
Example:
Based on .proto
file:
PrepareAsyncClientStreaming | A pointer to the generated, async version of the gRPC method. The async version starts with PrepareAsync . |
Executor | The executor type, must be capable of referring to a agrpc::GrpcContext . |
Per-Operation Cancellation
Terminal and partial. Cancellation is performed by invoking grpc::ClientContext::TryCancel. After successful cancellation no further operations may be started on the rpc (except finish
). Operations are also cancelled when the deadline of the rpc has been reached (see grpc::ClientContext::set_deadline).
|
inlinestaticconstexprnoexcept |
Name of the gRPC service.
Equal to the generated Service::service_full_name()
.
E.g. for the .proto
schema
the return value would be "example.v1.Example"
.
|
inlinestaticconstexprnoexcept |
Name of the gRPC method.
E.g. for agrpc::ClientRPC<&example::Example::Stub::PrepareAsyncMyMethod>
the return value would be "MyMethod"
.
|
inline |
Start a client-streaming request.
stub | The Stub that corresponds to the gRPC method. |
response | The response message, will be filled by the server upon finishing this rpc. Must remain alive until this rpc is finished. |
token | A completion token like asio::yield_context or agrpc::use_sender . The completion signature is void(bool) . true means that the rpc was started successfully. If it is false , then call finish to obtain error details. |
|
inline |
Read initial metadata.
Request notification of the reading of the initial metadata.
This call is optional.
Side effect:
agrpc::send_initial_metadata
) but waits for a message from the client instead then this function won't complete until write()
is called.token | A completion token like asio::yield_context or agrpc::use_sender . The completion signature is void(bool) . true indicates that the metadata was read. If it is false , then the call is dead. |
|
inline |
Send a message to the server.
WriteOptions options is used to set the write options of this message, otherwise identical to: write(request, token)
.
|
inline |
Send a message to the server.
Only one write may be outstanding at any given time. May not be called concurrently with read_initial_metadata
.
request | The request message, save to delete when this function returns, unless a deferred completion token is used like agrpc::use_sender or asio::deferred . |
token | A completion token like asio::yield_context or agrpc::use_sender . The completion signature is void(bool) . true means that the data is going to go to the wire. If it is false , it is not going to the wire because the call is already dead (i.e., canceled, deadline expired, other side dropped the channel, etc). |
|
inline |
Finish the rpc.
Indicate that the stream is to be finished and request notification for when the call has been ended.
May not be used concurrently with other operations and may only be called once.
The operation will finish when either:
Note that implementations of this method attempt to receive initial metadata from the server if initial metadata has not been received yet.
Side effect:
start
.token | A completion token like asio::yield_context or agrpc::use_sender . The completion signature is void(grpc::Status) . |
|
inlinenoexceptinherited |
Get the executor.
Thread-safe
|
inlinenoexceptinherited |
Get the scheduler.
Thread-safe
|
inlinenoexceptinherited |