Asynchronous gRPC with Asio/unified executors
APACHE-2.0 License
Bot releases are hidden (Show)
AGRPC_
macros from leaking into user code.operator bool
and swap
to agrpc::ServerRPCPtr
.Published by Tradias 8 months ago
agrpc::ServerRPC
, agrpc::ClientRPC
and agrpc::register_x
functions.asio-grpcConfig.cmake
no longer calls find_package
for all possible backends.asio::execution
functions.ASIO_GRPC_USE_BOOST_CONTAINER
and ASIO_GRPC_USE_RECYCLING_ALLOCATOR
cmake options.The agrpc::Server/ClientRPC
API is not understood by Microsoft's Intellisense. If that bothers you then please react to this bug ticket.
Published by Tradias 9 months ago
stdexec::schedule(grpc_executor)
.agrpc::register_sender_rpc_handler
in stdexec returns exec::task
.grpc::ServerAsyncX
types in several places. This only lead to compilation errors in certain gRPC versions (~1.30-1.40).writes_done
during finish
if a previous write
or read_initial_metadata
ended in false
in the streaming ClientRPCs.ServerRPC::finish
documentation.file(GLOB)
to create check-header-syntax
target to avoid forgetting to add a new header to the list.asio-grpc-check-header-syntax
target in the Ubuntu/20.04/Default pipeline.Published by Tradias 10 months ago
Published by Tradias 10 months ago
This will likely be the last release before v3.
agrpc::Alarm
will now use the set_done
/set_stopped
channel when cancelled, instead of sending a bool
through the set_value
channel.asio::execution
the StopToken was obtained by calling asio::get_associated_cancellation_slot
on the receiver. An unstoppable token is now used instead. Note that asio::execution
is deprecated and should no longer be used.execution
may now be used within the same application. Simply link with asio-grpc::asio-grpc(-standalone-asio)
and asio-grpc::asio-grpc-(unifex|stdexec)
.execution::get_scheduler
support to I/O objects.[[nodiscard]]
.asio-grpc.natvis
. Also add support for stdexec
. To learn how natvis files can improve your debugging experience check out the Visual Studio or Visual Studio Code documentation.agrpc::Waiter.initiate
for sender/receiver. Currently only the set_value
channel is forwarded to the waiting operation.agrpc::process_grpc_tag
work properly with unifex/stdexec instead of silently be a no-op.register_yield_rpc_handler
with standalone Asio 1.24.0+.asio::execution
with Asio 1.30.0+ / Boost 1.84+.Published by Tradias 10 months ago
agrpc::register_callback_rpc_handler
for setting up request handling with agrpc::ServerRPCPtr
, a dynamically allocated ServerRPC which can be used to implement non-coroutine based gRPC servers.std::execution
) in the form of a new CMake target asio-grpc::asio-grpc-stdexec
.asio::experimental::use_promise
might now return a different type due to the implementation of Asio's optional requirement on asynchronous operations: The operation's associated I/O executor may be exposed via the Initiation function object's executor_type type alias and get_executor() member function.
ServerRPC::wait_for_done
and Waiter::wait
.asio::detached
in examples since it swallows exceptions.register_awaitable_rpc_handler
and register_yield_rpc_handler
obtain the executor used to spawn the coroutine.Published by Tradias 12 months ago
This release prepares asio-grpc for a large trim down in the next major release by adding an API that follows Asio's I/O object model more closely, avoids the pitfalls of the current API and provides more customization options.
The following headers should be considered deprecated:
bind_allocator.hpp
, cancel_safe.hpp
, default_completion_token.hpp
, get_completion_queue.hpp
, grpc_initiate.hpp
, grpc_stream.hpp
, notify_when_done.hpp
, repeatedly_request_context.hpp
, repeatedly_request.hpp
, rpc.hpp
, use_awaitable.hpp
, wait.hpp
agrpc::ServerRPC
, new API for asynchronous servers.agrpc::register_awaitable_request_handler
, agrpc::register_yield_request_handler
and agrpc::register_sender_request_handler
functions for setting up request handling with agrpc::ServerRPC
.agrpc::ClientRPC
API:
agrpc::ClientRPCGenericUnary
to agrpc::GenericUnaryClientRPC
.agrpc::ClientRPCGenericStreaming
to agrpc::GenericStreamingClientRPC
.start
, read_initial_metadata
and finish
member functions.void*
in ClientRPC
, BasicAlarm
and notify_one_state_change
asynchronous operations.ClientRPC
, BasicAlarm
and notify_one_state_change
asynchronous operations.Published by Tradias about 1 year ago
agrpc::ClientRPC
and agrpc::ClientRPCType
.client_rpc.hpp
.asio::use_awaitable
is no longer the default completion token.grpc::ClientContext
, it can be customized during construction or later access using context()
.start()
, request()
has been removed.finish()
and writes_done()
no longer guard against being called multiple times.agrpc::CLIENT_GENERIC_X_RPC
with agrpc::ClientRPCType::GENERIC_X
.agrpc::ClientRPCGenericUnary<Executor>
and agrpc::ClientRPCGenericStreaming<Executor>
.agrpc::HealthCheckService
.cancel()
to agrpc::Alarm
.agrpc::repeatedly_request
.NotfiyWhenDoneFn
Published by Tradias over 1 year ago
agrpc::RPC
's RPCType deduction because it causes ICE since Visual Studio 17.5 (C++20 only). See bug report.Published by Tradias over 1 year ago
unsynchronized_pool_resource
. This makes selecting between <memory_resource>
, Boost.Container and asio::recycling_allocator
obsolete. All related CMake options have been marked deprecated and only affect uses_allocator
specializations now. They will be removed in version 3 which will always use std::uses_allocator
.agrpc::pmr
namespace are deprecated and will be removed in v3.ASIO_GRPC_BUILD_EXAMPLES
which enables compilation of just examples without tests. Also, libunifex is now treated as an optional dependency.agrpc::run*
consumes a high amount of CPU resources when the GrpcContext had already stopped while the second argument (typically an io_context) had work left to do. To resolve that, agrpc::run*
will now end when both contexts are stopped using new functions that were added to the RunTraits.Published by Tradias almost 2 years ago
agrpc::RPC
.<memory_resource>
or Boost.Container. This can be handy in combination with libc++ and standalone Asio to avoid taking a dependency on Boost.agrpc::GrpcContext{std::make_unique<grpc::CompletionQueue>()}
, use the new default constructor instead.agrpc::CancelSafe::is_running
has been renamed to is_wait_pending()
because it never reported whether the asynchronous operation is still running but instead whether a wait is currently pending.grpc::WriteOptions::set_last_message
on a high-level client streaming RPC incorrectly completes with true
.agprc::notify_when_done
is deallocated during GrpcContext destruction, leading to double free because the lifetime of the operation state is expected to be handled by the connector.asio::deferred
for agrpc::RPC::finish
and agrpc::RPC::writes_done
does not compile.agrpc::Alarm::wait
does not extend the lifetime of the alarm correctly when using completion tokens like asio::deferred
.ASIO_GRPC_USE_BOOST_CONTAINER
CMake variable when using asio-grpc with add_subdirectory
.notify_when_done
operation state by two pointers.agrpc::RPC::read_initial_metadata
may not be called concurrently with write
.add_subdirectory
-consumption of asio-grpc.Published by Tradias almost 2 years ago
agrpc::grpc_initiate
version would.agrpc::grpc_initiate
, use the above functions instead.Published by Tradias almost 2 years ago
agrpc::RPC<>::service/method_name()
:package example.v1;
service Example { rpc Unary(Request) returns (Response) {} }
using RPC = agrpc::RPC<&example::v1::Example::Stub::PrepareAsyncUnary>;
static_assert(RPC::service_name() == "example.v1.Example");
static_assert(RPC::method_name() == "Unary");
agrpc::Alarm
, an I/O object that wraps grpc::Alarm
. A safer alternative to the agrpc::wait
free function. Additionally supports ad-hoc waits which automatically extend the lifetime of the underlying gRPC alarm, for example with a callback:agrpc::Alarm(grpc_context).wait(deadline, [](bool ok, agrpc::Alarm&& alarm) {});
agrpc::repeatedly_request
, make a copy of the request handler to avoid lifetime surprises when the handler returns unifex::task<>
.agrpc::read
and agrpc::wait
, as well as the high-level client API.Published by Tradias about 2 years ago
asio_grpc_protobuf_generate
, check the validity of IMPORT_DIRS
at CMake configure time instead of build time.AGRPC_USE_BOOST_CONTAINER
can be used to choose between <memory_resource>
and Boost.Container.agrpc::repeatedly_request
crashes until 1.19.2.asio_grpc_protobuf_generate
.asio::execution::schedule(GrpcExecutor)
when compiling in C++17 using MSVC.agrpc::repeatedly_request
to a no-op when the completion handler does not support cancellation.std::move
and std::forward
with static_cast
and use a simpler version of std::tuple
to improve compile times.read_initial_metadata
will not complete until the server calls write_initial_metadata
or the client performs a write/finish.Published by Tradias about 2 years ago
Breaking change: All headers now use snake_case instead of camelCase, e.g. #include <agrpc/asioGrpc.hpp>
becomes #include <agrpc/asio_grpc.hpp>
.
Breaking change: Two overloads for requesting unary RPCs have been removed, example: co_await agrpc::request(&example::v1::Example::Stub::AsyncUnary, stub, client_context, request)
. Please use other means of obtaining a reference to the agrpc::GrpcContext
and then call agrpc::request(&example::v1::Example::Stub::AsyncUnary, stub, client_context, request, grpc_context)
.
Breaking change: Unsafe overloads of agrpc::get_completion_queue
have been removed.
Breaking change: asio-grpcConfig.cmake will now autolink with gRPC::grpc++_unsecure
instead of gRPC::grpc++
. If you are using encrypted gRPC then you need to explicitly link with gRPC::grpc++
in your CMake files.
Breaking change: If the completion handler passed to an asynchronous operation does not have an associated allocator then asio-grpc will no longer attempt to retrieve one from the associated executor through asio::query(executor, asio::execution::allocator)
. This behavior had been deprecated in v1.6.0.
run_until(deadline)
to agrpc::GrpcContext
.PrepareAsync
overloads for requesting RPCs in a thread-safe manner.Async
overloads for requesting client-side streaming RPCs as they can lead to race-conditions.agrpc::BasicGrpcStream
overload to agrpc::get_completion_queue
.agrpc::AllocatorBinder
fully constexpr compatible.std::aligned_storage
since it is deprecated in C++23.ServerShutdown
that is used in examples thread-safe.--build-and-test
command for the asio-grpc-cmake test. Also use an older version of CMake (3.16) for that test.Published by Tradias over 2 years ago
agrpc::request
and agrpc::repeatedly_request
for generic RPCs.agrpc::request
for starting a client-side unary request. The last argument to this function is a agrpc::GrpcContext
instead of a CompletionToken because the function completes immediately.agrpc::GrpcContext.run_completion_queue()/poll_completion_queue()
which only process events from the grpc::CompletionQueue
. They can be used as a better performing alternative to run()/poll()
where the GrpcContext is not used as an Asio execution context.std::unique_ptr
. (Except stubs which will be addressed in the next release)agrpc::CancelSafe
. Compared to the previous release it now takes a completion signature as template argument, example: Change agrpc::CancelSafe<bool>
to agrpc::CancelSafe<void(bool)>
agrpc::GrpcStream
, an IoObject-like class for handling RPCs in a cancellation safe manner. See the new handle_topic_subscription
example on how it can be used to write Golang/Rust select-style code.agrpc::PollContext
with a more optimized free function agrpc::run
that can be used to run an asio::io_context
and agrpc::GrpcContext
in the same thread.gh-pages
branch.Published by Tradias over 2 years ago
agrpc::CancelSafe
, a utility to make RPC step functions compatible with Asio's cancellation mechanism.agrpc::PollContext
now uses a configurable backoff to avoid wasting CPU resources during GrpcContext idle time.agrpc::GrpcContext::run
and poll
now return a boolean indicating whether at least one operation has been processed."visualizerFile"
field in launch.json.(BOOST_)ASIO_NO_TS_EXECUTORS
now hides members functions of the agrpc::GrpcExecutor
related to Networking TS executors: context()
, on_work_started()
, on_work_finished()
, dispatch()
, defer()
and post()
.agrpc::bind_allocator(allocator, completion_token)
or asio::bind_allocator
instead.(BOOST_)ASIO_HAS_DEDUCED_XXX_TRAIT
macros is no longer required when compiling with MSVC in C++17.polymorphic_allocator
as the associated allocator of the completion handler passed to agrpc::repeatedly_request
did not compile in C++20. Likewise, using std::allocator_traits<polymorphic_allocator>::construct
would propagate the allocator to the constructor of agrpc::GrpcContext
, agrpc::GrpcExecutor
and agrpc::AllocatorBinder
which was rather unexpected.agrpc::GrpcExecutor
would not compile on older compilers if the allocator is not comparable, e.g. because it is std::allocator<void>
.relationship::fork
when querying a agrpc::GrpcExecutor
for its relationship since that is the only supported setting. Preferring a different relationship property from the executor now returns the executor unchanged.asio::allocator_binder
when using Boost.Asio 1.79.0 or Asio 1.22.1.agrpc/grpcContext.hpp
now only provides forward declarations of the GrpcContext and its member functions. If you experience use of undefined function issues then add an include to agrpc/grpcExecutor.hpp
.<variant>
.-fsyntax-only
//Zs
on public header files and build that target as part of Github Actions.Published by Tradias over 2 years ago
agrpc::repeatedly_request
with awaitable which could lead to an early stop of an agrpc::GrpcContext
or crash during destruction.Published by Tradias over 2 years ago
agrpc::bind_allocator
which associates an allocator to a completion token's completion handler. Similar to the new asio::bind_allocator
except that it also works in older versions of Asio and provides empty class optimization on the allocator.agrpc::GrpcContext.poll()
which processes only completed handler.agrpc::GrpcContext
to mimic that of asio::io_context
. Operations submitted to a stopped context will no longer be discarded and instead processed the next time run()
or poll()
is called.agrpc::PollContext
which repeatedly polls a agrpc::GrpcContext
within a different execution context. An example showing how this can be used to run an asio::io_context
and agrpc::GrpcContext
on the same thread has been added as well.agrpc::repeatedly_request
with awaitable.agrpc::use_scheduler
.