asio-grpc v3.1.0
Asynchronous gRPC with Asio/unified executors
|
I/O object for client-side, unary rpcs. More...
#include <agrpc/client_rpc.hpp>
Public Member Functions | |
void | start (StubT &stub, const RequestT &req) |
Start the rpc. More... | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
auto | finish (ResponseT &response, CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Finish the rpc. More... | |
auto | read_initial_metadata (CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Read initial metadata. 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... | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
static auto | request (agrpc::GrpcContext &grpc_context, StubT &stub, grpc::ClientContext &context, const RequestT &request, ResponseT &response, CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Perform a request. More... | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
static auto | request (const Executor &executor, StubT &stub, grpc::ClientContext &context, const RequestT &request, ResponseT &response, CompletionToken &&token=detail::DefaultCompletionTokenT< Executor >{}) |
Start a generic unary request (executor overload) | |
Static Public Attributes | |
static constexpr agrpc::ClientRPCType | TYPE = agrpc::ClientRPCType::UNARY |
The rpc type. | |
I/O object for client-side, unary rpcs.
Example:
Alternative version that waits the server's initial metadata first:
Based on .proto
file:
PrepareAsyncUnary | 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. Operations are also cancelled when the deadline of the rpc has been reached (see grpc::ClientContext::set_deadline).
|
inlinestaticconstexprnoexceptinherited |
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"
.
|
inlinestaticconstexprnoexceptinherited |
Name of the gRPC method.
E.g. for agrpc::ClientRPC<&example::Example::Stub::PrepareAsyncMyMethod>
the return value would be "MyMethod"
.
|
inlinestaticinherited |
Perform a request.
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 . |
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(grpc::Status) . Use grpc::Status::ok() to check whether the request was successful. |
|
inlineinherited |
Start the rpc.
req | The request message, save to delete when this function returns, unless a deferred completion token like agrpc::use_sender or asio::deferred is used. |
|
inlineinherited |
Finish the rpc.
Receive the server's response message and final status for the call.
This operation will finish when either:
Side effect:
token | A completion token like asio::yield_context or agrpc::use_sender . The completion signature is void(grpc::Status) . |
|
inlineinherited |
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. |
|
inlinenoexceptinherited |
Get the executor.
Thread-safe
|
inlinenoexceptinherited |
Get the scheduler.
Thread-safe
|
inlinenoexceptinherited |