Skip to content

Commit e09a53f

Browse files
committed
Removes payload rotation from request.
The user can simply call HELLO before other commands. Altering the order of requests makes it impossible to declare responses.
1 parent ec8a1c7 commit e09a53f

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

examples/boost_redis.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,4 @@
44
* accompanying file LICENSE.txt)
55
*/
66

7-
#include <boost/redis/config.hpp>
8-
#include <boost/redis/connection.hpp>
9-
#include <boost/redis/request.hpp>
10-
#include <boost/asio/detached.hpp>
11-
#include <boost/asio/deferred.hpp>
12-
#include <boost/asio/consign.hpp>
13-
147
#include <boost/redis/src.hpp>

include/boost/redis/request.hpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class request {
9999
{
100100
payload_.clear();
101101
commands_ = 0;
102+
has_hello_priority_ = false;
102103
}
103104

104105
/// Calls std::string::reserve on the internal storage.
@@ -139,14 +140,12 @@ class request {
139140
template <class... Ts>
140141
void push(std::string_view cmd, Ts const&... args)
141142
{
142-
auto const size_before = std::size(payload_);
143143
auto constexpr pack_size = sizeof...(Ts);
144144
resp3::add_header(payload_, resp3::type::array, 1 + pack_size);
145145
resp3::add_bulk(payload_, cmd);
146146
resp3::add_bulk(payload_, std::tie(std::forward<Ts const&>(args)...));
147-
auto const size_after = std::size(payload_);
148147

149-
check_cmd(cmd, size_after - size_before);
148+
check_cmd(cmd);
150149
}
151150

152151
/** @brief Appends a new command to the end of the request.
@@ -194,7 +193,6 @@ class request {
194193
if (begin == end)
195194
return;
196195

197-
auto const size_before = std::size(payload_);
198196
auto constexpr size = resp3::bulk_counter<value_type>::size;
199197
auto const distance = std::distance(begin, end);
200198
resp3::add_header(payload_, resp3::type::array, 2 + size * distance);
@@ -204,9 +202,7 @@ class request {
204202
for (; begin != end; ++begin)
205203
resp3::add_bulk(payload_, *begin);
206204

207-
auto const size_after = std::size(payload_);
208-
209-
check_cmd(cmd, size_after - size_before);
205+
check_cmd(cmd);
210206
}
211207

212208
/** @brief Appends a new command to the end of the request.
@@ -249,7 +245,6 @@ class request {
249245
if (begin == end)
250246
return;
251247

252-
auto const size_before = std::size(payload_);
253248
auto constexpr size = resp3::bulk_counter<value_type>::size;
254249
auto const distance = std::distance(begin, end);
255250
resp3::add_header(payload_, resp3::type::array, 1 + size * distance);
@@ -258,9 +253,7 @@ class request {
258253
for (; begin != end; ++begin)
259254
resp3::add_bulk(payload_, *begin);
260255

261-
auto const size_after = std::size(payload_);
262-
263-
check_cmd(cmd, size_after - size_before);
256+
check_cmd(cmd);
264257
}
265258

266259
/** @brief Appends a new command to the end of the request.
@@ -308,18 +301,13 @@ class request {
308301
}
309302

310303
private:
311-
void check_cmd(std::string_view cmd, std::size_t n)
304+
void check_cmd(std::string_view cmd)
312305
{
313306
if (!detail::has_response(cmd))
314307
++commands_;
315308

316-
if (cmd == "HELLO") {
309+
if (cmd == "HELLO")
317310
has_hello_priority_ = cfg_.hello_with_priority;
318-
if (has_hello_priority_) {
319-
auto const shift = std::size(payload_) - n;
320-
std::rotate(std::begin(payload_), std::begin(payload_) + shift, std::end(payload_));
321-
}
322-
}
323311
}
324312

325313
config cfg_;

0 commit comments

Comments
 (0)