7#include <boost/asio.hpp>
8#if defined(BOOST_ASIO_HAS_CO_AWAIT)
10#include "common/common.hpp"
12namespace net = boost::asio;
13namespace resp3 = aedis::resp3;
17auto run(std::shared_ptr<connection> conn, std::string host, std::string port) -> net::awaitable<void>
19 co_await connect(conn, host, port);
20 co_await conn->async_run();
23auto hello(std::shared_ptr<connection> conn) -> net::awaitable<void>
28 co_await conn->async_exec(req);
31auto ping(std::shared_ptr<connection> conn) -> net::awaitable<void>
34 req.
push(
"PING",
"Hello world");
36 std::tuple<std::string> resp;
37 co_await conn->async_exec(req,
adapt(resp));
39 std::cout <<
"PING: " << std::get<0>(resp) << std::endl;
42auto quit(std::shared_ptr<connection> conn) -> net::awaitable<void>
47 co_await conn->async_exec(req);
51auto co_main(std::string host, std::string port) -> net::awaitable<void>
53 auto ex =
co_await net::this_coro::executor;
54 auto conn = std::make_shared<connection>(ex);
55 net::co_spawn(ex,
run(conn, host, port), net::detached);
void push(std::string_view cmd, Ts const &... args)
Appends a new command to the end of the request.
auto adapt(std::size_t max_read_size=(std::numeric_limits< std::size_t >::max)()) noexcept
Creates an adapter that ignores responses.
operation
Connection operations that can be cancelled.
@ run
Refers to connection::async_run operations.