7#ifndef BOOST_REDIS_RUNNER_HPP
8#define BOOST_REDIS_RUNNER_HPP
10#include <boost/redis/config.hpp>
11#include <boost/redis/detail/connection_logger.hpp>
12#include <boost/redis/error.hpp>
13#include <boost/redis/operation.hpp>
14#include <boost/redis/request.hpp>
15#include <boost/redis/response.hpp>
17#include <boost/asio/compose.hpp>
18#include <boost/asio/coroutine.hpp>
22namespace boost::redis::detail {
24void push_hello(config
const& cfg, request& req);
29template <
class Handshaker,
class Connection>
31 Handshaker* handshaker_ =
nullptr;
32 Connection* conn_ =
nullptr;
33 asio::coroutine coro_{};
36 void operator()(Self& self, system::error_code ec = {}, std::size_t = 0)
38 BOOST_ASIO_CORO_REENTER(coro_)
40 handshaker_->add_hello();
44 handshaker_->hello_req_,
45 any_adapter(handshaker_->hello_resp_),
47 conn_->logger_.on_hello(ec, handshaker_->hello_resp_);
55 if (handshaker_->has_error_in_response()) {
66template <
class Executor>
67class resp3_handshaker {
69 void set_config(config
const& cfg) { cfg_ = cfg; }
71 template <
class Connection,
class CompletionToken>
72 auto async_hello(Connection& conn, CompletionToken token)
74 return asio::async_compose<CompletionToken, void(system::error_code)>(
75 hello_op<resp3_handshaker, Connection>{
this, &conn},
81 template <
class,
class>
friend struct hello_op;
86 if (hello_resp_.has_value())
87 hello_resp_.value().clear();
88 push_hello(cfg_, hello_req_);
91 bool has_error_in_response() const noexcept
93 if (!hello_resp_.has_value())
96 auto f = [](
auto const& e) {
97 switch (e.data_type) {
100 default:
return false;
104 return std::any_of(std::cbegin(hello_resp_.value()), std::cend(hello_resp_.value()), f);
void clear()
Clears the request preserving allocated memory.
adapter::result< std::vector< resp3::node > > generic_response
A generic response to a request.
@ resp3_hello
Resp3 hello command error.
@ run
Refers to connection::async_run operations.