7#ifndef BOOST_REDIS_RUNNER_HPP
8#define BOOST_REDIS_RUNNER_HPP
10#include <boost/redis/config.hpp>
11#include <boost/redis/request.hpp>
12#include <boost/redis/response.hpp>
13#include <boost/redis/error.hpp>
14#include <boost/redis/logger.hpp>
15#include <boost/redis/operation.hpp>
16#include <boost/asio/compose.hpp>
17#include <boost/asio/coroutine.hpp>
23namespace boost::redis::detail
26void push_hello(config
const& cfg, request& req);
31template <
class Handshaker,
class Connection,
class Logger>
33 Handshaker* handshaker_ =
nullptr;
34 Connection* conn_ =
nullptr;
36 asio::coroutine coro_{};
39 void operator()(Self& self, system::error_code ec = {}, std::size_t = 0)
41 BOOST_ASIO_CORO_REENTER (coro_)
43 handshaker_->add_hello();
46 conn_->async_exec(handshaker_->hello_req_, any_adapter(handshaker_->hello_resp_), std::move(self));
47 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)
72 template <
class Connection,
class Logger,
class CompletionToken>
73 auto async_hello(Connection& conn, Logger l, CompletionToken token)
75 return asio::async_compose
77 , void(system::error_code)
78 >(hello_op<resp3_handshaker, Connection, Logger>{
this, &conn, l}, token, conn);
82 template <
class,
class,
class>
friend struct hello_op;
87 if (hello_resp_.has_value())
88 hello_resp_.value().clear();
89 push_hello(cfg_, hello_req_);
92 bool has_error_in_response() const noexcept
94 if (!hello_resp_.has_value())
97 auto f = [](
auto const& e)
99 switch (e.data_type) {
102 default:
return false;
106 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.