From 5cdd696f2ff356394dada3e9fb5dfb2418d7fac4 Mon Sep 17 00:00:00 2001 From: Marcelo Zimbres Date: Sat, 18 Sep 2021 14:14:46 +0200 Subject: [PATCH] Renames class. --- Makefile.am | 2 +- examples/async_basic.cpp | 32 +-- include/aedis/aedis.hpp | 2 +- include/aedis/command.hpp | 3 +- include/aedis/impl/command.ipp | 4 +- include/aedis/impl/read.ipp | 44 ---- .../aedis/impl/{pipeline.ipp => response.ipp} | 0 include/aedis/impl/response_adapter.ipp | 44 ++++ include/aedis/impl/src.hpp | 4 +- include/aedis/impl/type.ipp | 20 +- include/aedis/impl/write.ipp | 2 +- include/aedis/read.hpp | 62 +++-- include/aedis/{pipeline.hpp => request.hpp} | 96 +++---- .../{response_buffers.hpp => response.hpp} | 12 +- ...onse_adapters.hpp => response_adapter.hpp} | 157 ++++++------ include/aedis/response_adapter_base.hpp | 35 ++- include/aedis/type.hpp | 30 +-- include/aedis/utils.hpp | 2 +- include/aedis/version.hpp | 2 +- include/aedis/write.hpp | 30 +-- tests/general.cpp | 240 +++++++++--------- 21 files changed, 410 insertions(+), 413 deletions(-) delete mode 100644 include/aedis/impl/read.ipp rename include/aedis/impl/{pipeline.ipp => response.ipp} (100%) create mode 100644 include/aedis/impl/response_adapter.ipp rename include/aedis/{pipeline.hpp => request.hpp} (80%) rename include/aedis/{response_buffers.hpp => response.hpp} (80%) rename include/aedis/{response_adapters.hpp => response_adapter.hpp} (69%) diff --git a/Makefile.am b/Makefile.am index bf1e2253..37525477 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,7 +34,7 @@ libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/write.hpp libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/read.hpp libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/parser.hpp libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/response_adapter_base.hpp -libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/response_buffers.hpp +libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/responses.hpp libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/utils.hpp libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/impl/read.ipp libaedis_a_SOURCES += $(top_srcdir)/include/aedis/detail/impl/parser.ipp diff --git a/examples/async_basic.cpp b/examples/async_basic.cpp index ffb10235..e361a4aa 100644 --- a/examples/async_basic.cpp +++ b/examples/async_basic.cpp @@ -10,40 +10,40 @@ using namespace aedis; net::awaitable -example(net::ip::tcp::socket& socket, std::queue& pipelines) +example(net::ip::tcp::socket& socket, std::queue& requests) { - pipelines.push({}); - pipelines.back().hello("3"); + requests.push({}); + requests.back().hello("3"); - response_buffers buffers; - consumer_state cs{buffers}; + response resp; + consumer_state cs{resp}; for (;;) { auto const type = - co_await async_consume(socket, pipelines, cs, net::use_awaitable); + co_await async_consume(socket, requests, cs, net::use_awaitable); - if (type == resp3::type::push) { + if (type == resp3::type::flat_push) { std::cout << "Event: " << "(" << type << ")" << std::endl; continue; } - auto const cmd = pipelines.front().commands.front(); + auto const cmd = requests.front().commands.front(); std::cout << "Event: " << cmd << " (" << type << ")" << std::endl; switch (cmd) { case command::hello: { - prepare_queue(pipelines); - pipelines.back().ping(); - pipelines.back().subscribe("some-channel"); + prepare_next(requests); + requests.back().ping(); + requests.back().subscribe("some-channel"); } break; case command::publish: break; case command::quit: break; case command::ping: { - prepare_queue(pipelines); - pipelines.back().publish("some-channel", "Some message"); - pipelines.back().quit(); + prepare_next(requests); + requests.back().publish("some-channel", "Some message"); + requests.back().quit(); } break; default: { } } @@ -59,7 +59,7 @@ int main() net::ip::tcp::socket socket{ioc}; net::connect(socket, res); - std::queue pipelines; - co_spawn(ioc, example(socket, pipelines), net::detached); + std::queue requests; + co_spawn(ioc, example(socket, requests), net::detached); ioc.run(); } diff --git a/include/aedis/aedis.hpp b/include/aedis/aedis.hpp index c8f3c1df..5f9f77e1 100644 --- a/include/aedis/aedis.hpp +++ b/include/aedis/aedis.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include diff --git a/include/aedis/command.hpp b/include/aedis/command.hpp index cd2dad49..202ebe79 100644 --- a/include/aedis/command.hpp +++ b/include/aedis/command.hpp @@ -74,7 +74,8 @@ enum class command }; std::string to_string(command c); -std::ostream& operator<<(std::ostream& os, command c); } // aedis +std::ostream& operator<<(std::ostream& os, aedis::command c); + diff --git a/include/aedis/impl/command.ipp b/include/aedis/impl/command.ipp index 3b544f68..0d5601fc 100644 --- a/include/aedis/impl/command.ipp +++ b/include/aedis/impl/command.ipp @@ -66,11 +66,11 @@ std::string to_string(command c) } } +} // aedis + std::ostream& operator<<(std::ostream& os, aedis::command c) { os << to_string(c); return os; } -} // aedis - diff --git a/include/aedis/impl/read.ipp b/include/aedis/impl/read.ipp deleted file mode 100644 index 444a2dc5..00000000 --- a/include/aedis/impl/read.ipp +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2019 - 2021 Marcelo Zimbres Silva (mzimbres at gmail dot com) - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include - -namespace aedis { - -response_adapter_base* -select_adapter(response_adapters& adapters, resp3::type type, command cmd) -{ - if (type == resp3::type::push) - return &adapters.resp_push; - - if (cmd == command::exec) - return &adapters.resp_transaction; - - switch (type) { - case resp3::type::set: return &adapters.resp_set; - case resp3::type::map: return &adapters.resp_map; - case resp3::type::attribute: return &adapters.resp_attribute; - case resp3::type::array: return &adapters.resp_array; - case resp3::type::simple_error: return &adapters.resp_simple_error; - case resp3::type::simple_string: return &adapters.resp_simple_string; - case resp3::type::number: return &adapters.resp_number; - case resp3::type::doublean: return &adapters.resp_double; - case resp3::type::big_number: return &adapters.resp_big_number; - case resp3::type::boolean: return &adapters.resp_boolean; - case resp3::type::blob_error: return &adapters.resp_blob_error; - case resp3::type::blob_string: return &adapters.resp_blob_string; - case resp3::type::verbatim_string: return &adapters.resp_verbatim_string; - case resp3::type::streamed_string_part: return &adapters.resp_streamed_string_part; - case resp3::type::null: return &adapters.resp_ignore; - default: { - throw std::runtime_error("response_buffers"); - return nullptr; - } - } -} - -} // aedis diff --git a/include/aedis/impl/pipeline.ipp b/include/aedis/impl/response.ipp similarity index 100% rename from include/aedis/impl/pipeline.ipp rename to include/aedis/impl/response.ipp diff --git a/include/aedis/impl/response_adapter.ipp b/include/aedis/impl/response_adapter.ipp new file mode 100644 index 00000000..57e84e30 --- /dev/null +++ b/include/aedis/impl/response_adapter.ipp @@ -0,0 +1,44 @@ +/* Copyright (c) 2019 - 2021 Marcelo Zimbres Silva (mzimbres at gmail dot com) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#include + +namespace aedis { + +response_adapter_base* +select_adapter(response_adapter& adapters, resp3::type type, command cmd) +{ + if (type == resp3::type::flat_push) + return &adapters.flat_push; + + if (cmd == command::exec) + return &adapters.array; + + switch (type) { + case resp3::type::flat_set: return &adapters.flat_set; + case resp3::type::flat_map: return &adapters.flat_map; + case resp3::type::flat_attribute: return &adapters.flat_attribute; + case resp3::type::flat_array: return &adapters.flat_array; + case resp3::type::simple_error: return &adapters.simple_error; + case resp3::type::simple_string: return &adapters.simple_string; + case resp3::type::number: return &adapters.number; + case resp3::type::doublean: return &adapters.doublean; + case resp3::type::big_number: return &adapters.big_number; + case resp3::type::boolean: return &adapters.boolean; + case resp3::type::blob_error: return &adapters.blob_error; + case resp3::type::blob_string: return &adapters.blob_string; + case resp3::type::verbatim_string: return &adapters.verbatim_string; + case resp3::type::streamed_string_part: return &adapters.streamed_string_part; + case resp3::type::null: return &adapters.resp_ignore; + default: { + throw std::runtime_error("response_buffers"); + return nullptr; + } + } +} + +} // aedis diff --git a/include/aedis/impl/src.hpp b/include/aedis/impl/src.hpp index 7958443e..c9cc9fa2 100644 --- a/include/aedis/impl/src.hpp +++ b/include/aedis/impl/src.hpp @@ -7,8 +7,8 @@ #include #include -#include +#include #include -#include +#include #include diff --git a/include/aedis/impl/type.ipp b/include/aedis/impl/type.ipp index f01a3263..bf7b9898 100644 --- a/include/aedis/impl/type.ipp +++ b/include/aedis/impl/type.ipp @@ -17,10 +17,11 @@ std::string to_string(type t) { switch (t) { EXPAND_TYPE_CASE(array); - EXPAND_TYPE_CASE(push); - EXPAND_TYPE_CASE(set); - EXPAND_TYPE_CASE(map); - EXPAND_TYPE_CASE(attribute); + EXPAND_TYPE_CASE(flat_array); + EXPAND_TYPE_CASE(flat_push); + EXPAND_TYPE_CASE(flat_set); + EXPAND_TYPE_CASE(flat_map); + EXPAND_TYPE_CASE(flat_attribute); EXPAND_TYPE_CASE(simple_string); EXPAND_TYPE_CASE(simple_error); EXPAND_TYPE_CASE(number); @@ -33,7 +34,6 @@ std::string to_string(type t) EXPAND_TYPE_CASE(blob_string); EXPAND_TYPE_CASE(streamed_string_part); EXPAND_TYPE_CASE(invalid); - EXPAND_TYPE_CASE(transaction); default: assert(false); } } @@ -52,11 +52,11 @@ type to_type(char c) case '(': return type::big_number; case '+': return type::simple_string; case '_': return type::null; - case '>': return type::push; - case '~': return type::set; - case '*': return type::array; - case '|': return type::attribute; - case '%': return type::map; + case '>': return type::flat_push; + case '~': return type::flat_set; + case '*': return type::flat_array; + case '|': return type::flat_attribute; + case '%': return type::flat_map; default: return type::invalid; } } diff --git a/include/aedis/impl/write.ipp b/include/aedis/impl/write.ipp index 13e76b4c..57c502da 100644 --- a/include/aedis/impl/write.ipp +++ b/include/aedis/impl/write.ipp @@ -9,7 +9,7 @@ namespace aedis { -bool prepare_queue(std::queue& reqs) +bool prepare_next(std::queue& reqs) { if (std::empty(reqs)) { reqs.push({}); diff --git a/include/aedis/read.hpp b/include/aedis/read.hpp index 698b6fd3..c66c8938 100644 --- a/include/aedis/read.hpp +++ b/include/aedis/read.hpp @@ -11,19 +11,17 @@ #include #include -#include +#include #include #include #include -#include +#include #include namespace aedis { -response_adapter_base* select_adapter(response_adapters& buffers, resp3::type t, command cmd); - // The parser supports up to 5 levels of nested structures. The first // element in the sizes stack is a sentinel and must be different from // 1. @@ -229,28 +227,28 @@ auto async_read_type( } /** Asynchronously reads the response from one command. The result is - * stored in the parameter buffers. + * stored in the parameter resps. */ template < class AsyncReadWriteStream, class Storage> net::awaitable> async_read_one( AsyncReadWriteStream& socket, Storage& buffer, - response_adapters& adapters, - std::queue const& reqs) + response_adapter& adapter, + std::queue const& reqs) { auto const type = co_await async_read_type(socket, buffer, net::use_awaitable); assert(type != resp3::type::invalid); auto cmd = command::unknown; - if (type != resp3::type::push) { + if (type != resp3::type::flat_push) { assert(!std::empty(reqs)); assert(!std::empty(reqs.front().commands)); cmd = reqs.front().commands.front(); } - auto* buf_adapter = select_adapter(adapters, type, cmd); - co_await async_read_one_impl(socket, buffer, *buf_adapter, net::use_awaitable); + auto* p = select_adapter(adapter, type, cmd); + co_await async_read_one_impl(socket, buffer, *p, net::use_awaitable); co_return std::make_pair(cmd, type); } @@ -262,13 +260,13 @@ net::awaitable> async_consume( AsyncReadWriteStream& socket, Storage& buffer, - response_buffers& bufs, - std::queue& reqs) + response& resp, + std::queue& reqs) { - response_adapters adapters{bufs}; - auto const res = co_await async_read_one(socket, buffer, adapters, reqs); + response_adapter adapter{resp}; + auto const res = co_await async_read_one(socket, buffer, adapter, reqs); - if (res.second == resp3::type::push) + if (res.second == resp3::type::flat_push) co_return res; reqs.front().commands.pop(); @@ -298,8 +296,8 @@ async_consume( struct consume_op { net::ip::tcp::socket& socket; std::string& buffer; - std::queue& pipelines; - response_adapters& adapters; + std::queue& requests; + response_adapter& adapter; resp3::type& m_type; net::coroutine& coro; @@ -311,7 +309,7 @@ struct consume_op { { reenter (coro) for (;;) { - yield async_write_some(socket, pipelines, std::move(self)); + yield async_write_some(socket, requests, std::move(self)); if (ec) { self.complete(ec, resp3::type::invalid); return; @@ -330,11 +328,11 @@ struct consume_op { yield { auto cmd = command::unknown; - if (m_type != resp3::type::push) - cmd = pipelines.front().commands.front(); + if (m_type != resp3::type::flat_push) + cmd = requests.front().commands.front(); - auto* adapter = select_adapter(adapters, m_type, cmd); - async_read_one_impl(socket, buffer, *adapter, std::move(self)); + auto* p = select_adapter(adapter, m_type, cmd); + async_read_one_impl(socket, buffer, *p, std::move(self)); } if (ec) { @@ -344,24 +342,24 @@ struct consume_op { yield self.complete(ec, m_type); - if (m_type != resp3::type::push) - pipelines.front().commands.pop(); + if (m_type != resp3::type::flat_push) + requests.front().commands.pop(); - } while (!std::empty(pipelines.front().commands)); - pipelines.pop(); - } while (std::empty(pipelines)); + } while (!std::empty(requests.front().commands)); + requests.pop(); + } while (std::empty(requests)); } } }; struct consumer_state { std::string buffer; - response_adapters adapters; + response_adapter adapter; net::coroutine coro; resp3::type type; - consumer_state(response_buffers& buffers) - : adapters{buffers} + consumer_state(response& resp) + : adapter{resp} , coro{net::coroutine()} , type {resp3::type::invalid} { } @@ -370,14 +368,14 @@ struct consumer_state { template auto async_consume( net::ip::tcp::socket& socket, - std::queue& pipelines, + std::queue& requests, consumer_state& cs, CompletionToken&& token) { return net::async_compose< CompletionToken, void(boost::system::error_code, resp3::type)>( - consume_op{socket, cs.buffer, pipelines, cs.adapters, cs.type, cs.coro}, token, socket); + consume_op{socket, cs.buffer, requests, cs.adapter, cs.type, cs.coro}, token, socket); } } // aedis diff --git a/include/aedis/pipeline.hpp b/include/aedis/request.hpp similarity index 80% rename from include/aedis/pipeline.hpp rename to include/aedis/request.hpp index 195ab819..47d6ab49 100644 --- a/include/aedis/pipeline.hpp +++ b/include/aedis/request.hpp @@ -110,14 +110,14 @@ void assemble(std::string& ret, std::string_view cmd, std::string_view key); /** A class to compose redis requests * - * A pipeline is composed of one or more redis commands and is + * A request is composed of one or more redis commands and is * refered to in the redis documentation as a pipeline, see * https://redis.io/topics/pipelining. * * The protocol version suported is RESP3, see * https://github.com/antirez/RESP3/blob/74adea588783e463c7e84793b325b088fe6edd1c/spec.md */ -class pipeline { +class request { public: std::string payload; std::queue commands; @@ -135,7 +135,7 @@ public: bool empty() const noexcept { return std::empty(payload); }; - /// Clears the pipeline. + /// Clears the request. void clear() { payload.clear(); @@ -172,42 +172,42 @@ public: commands.push(command::incr); } - /// Adds auth to the pipeline, see https://redis.io/commands/bgrewriteaof + /// Adds auth to the request, see https://redis.io/commands/bgrewriteaof void auth(std::string_view pwd) { resp3::assemble(payload, "AUTH", pwd); commands.push(command::auth); } - /// Adds bgrewriteaof to the pipeline, see https://redis.io/commands/bgrewriteaof + /// Adds bgrewriteaof to the request, see https://redis.io/commands/bgrewriteaof void bgrewriteaof() { resp3::assemble(payload, "BGREWRITEAOF"); commands.push(command::bgrewriteaof); } - /// Adds role to the pipeline, see https://redis.io/commands/role + /// Adds role to the request, see https://redis.io/commands/role void role() { resp3::assemble(payload, "ROLE"); commands.push(command::role); } - /// Adds bgsave to the pipeline, see //https://redis.io/commands/bgsave + /// Adds bgsave to the request, see //https://redis.io/commands/bgsave void bgsave() { resp3::assemble(payload, "BGSAVE"); commands.push(command::bgsave); } - /// Adds ping to the pipeline, see https://redis.io/commands/flushall + /// Adds ping to the request, see https://redis.io/commands/flushall void flushall() { resp3::assemble(payload, "FLUSHALL"); commands.push(command::flushall); } - /// Adds ping to the pipeline, see https://redis.io/commands/lpop + /// Adds ping to the request, see https://redis.io/commands/lpop void lpop(std::string_view key, int count = 1) { //if (count == 1) { @@ -225,42 +225,42 @@ public: commands.push(command::lpop); } - /// Adds ping to the pipeline, see https://redis.io/commands/subscribe + /// Adds ping to the request, see https://redis.io/commands/subscribe void subscribe(std::string_view key) { // The response to this command is a push. resp3::assemble(payload, "SUBSCRIBE", key); } - /// Adds ping to the pipeline, see https://redis.io/commands/unsubscribe + /// Adds ping to the request, see https://redis.io/commands/unsubscribe void unsubscribe(std::string_view key) { // The response to this command is a push. resp3::assemble(payload, "UNSUBSCRIBE", key); } - /// Adds ping to the pipeline, see https://redis.io/commands/get + /// Adds ping to the request, see https://redis.io/commands/get void get(std::string_view key) { resp3::assemble(payload, "GET", key); commands.push(command::get); } - /// Adds ping to the pipeline, see https://redis.io/commands/keys + /// Adds ping to the request, see https://redis.io/commands/keys void keys(std::string_view pattern) { resp3::assemble(payload, "KEYS", pattern); commands.push(command::keys); } - /// Adds ping to the pipeline, see https://redis.io/commands/hello + /// Adds ping to the request, see https://redis.io/commands/hello void hello(std::string_view version = "3") { resp3::assemble(payload, "HELLO", version); commands.push(command::hello); } - /// Adds ping to the pipeline, see https://redis.io/commands/sentinel + /// Adds ping to the request, see https://redis.io/commands/sentinel void sentinel(std::string_view arg, std::string_view name) { auto par = {name}; @@ -268,7 +268,7 @@ public: commands.push(command::sentinel); } - /// Adds ping to the pipeline, see https://redis.io/commands/append + /// Adds ping to the request, see https://redis.io/commands/append void append(std::string_view key, std::string_view msg) { auto par = {msg}; @@ -276,7 +276,7 @@ public: commands.push(command::append); } - /// Adds ping to the pipeline, see https://redis.io/commands/bitcount + /// Adds ping to the request, see https://redis.io/commands/bitcount void bitcount(std::string_view key, int start = 0, int end = -1) { auto const start_str = std::to_string(start); @@ -291,7 +291,7 @@ public: commands.push(command::bitcount); } - /// Adds ping to the pipeline, see https://redis.io/commands/rpush + /// Adds ping to the request, see https://redis.io/commands/rpush template void rpush(std::string_view key, Iter begin, Iter end) { @@ -299,14 +299,14 @@ public: commands.push(command::rpush); } - /// Adds ping to the pipeline, see https://redis.io/commands/rpush + /// Adds ping to the request, see https://redis.io/commands/rpush template void rpush( std::string_view key, std::initializer_list v) { return rpush(key, std::cbegin(v), std::cend(v)); } - /// Adds ping to the pipeline, see https://redis.io/commands/rpush + /// Adds ping to the request, see https://redis.io/commands/rpush template void rpush( std::string_view key, Range const& v) { @@ -315,7 +315,7 @@ public: rpush(key, cbegin(v), cend(v)); } - /// Adds ping to the pipeline, see https://redis.io/commands/lpush + /// Adds ping to the request, see https://redis.io/commands/lpush template void lpush(std::string_view key, Iter begin, Iter end) { @@ -329,7 +329,7 @@ public: resp3::assemble(payload, "PSUBSCRIBE", l, std::cbegin(dummy), std::cend(dummy)); } - /// Adds ping to the pipeline, see https://redis.io/commands/publish + /// Adds ping to the request, see https://redis.io/commands/publish void publish(std::string_view key, std::string_view msg) { auto par = {msg}; @@ -337,7 +337,7 @@ public: commands.push(command::publish); } - /// Adds ping to the pipeline, see https://redis.io/commands/set + /// Adds ping to the request, see https://redis.io/commands/set void set(std::string_view key, std::initializer_list args) { @@ -346,7 +346,7 @@ public: } // TODO: Find a way to assert the value type is a pair. - /// Adds ping to the pipeline, see https://redis.io/commands/hset + /// Adds ping to the request, see https://redis.io/commands/hset template void hset(std::string_view key, Range const& r) { @@ -358,7 +358,7 @@ public: commands.push(command::hset); } - /// Adds ping to the pipeline, see https://redis.io/commands/hincrby + /// Adds ping to the request, see https://redis.io/commands/hincrby void hincrby(std::string_view key, std::string_view field, int by) { auto by_str = std::to_string(by); @@ -367,7 +367,7 @@ public: commands.push(command::hincrby); } - /// Adds ping to the pipeline, see https://redis.io/commands/hkeys + /// Adds ping to the request, see https://redis.io/commands/hkeys void hkeys(std::string_view key) { auto par = {""}; @@ -375,28 +375,28 @@ public: commands.push(command::hkeys); } - /// Adds ping to the pipeline, see https://redis.io/commands/hlen + /// Adds ping to the request, see https://redis.io/commands/hlen void hlen(std::string_view key) { resp3::assemble(payload, "HLEN", {key}); commands.push(command::hlen); } - /// Adds ping to the pipeline, see https://redis.io/commands/hgetall + /// Adds ping to the request, see https://redis.io/commands/hgetall void hgetall(std::string_view key) { resp3::assemble(payload, "HGETALL", {key}); commands.push(command::hgetall); } - /// Adds ping to the pipeline, see https://redis.io/commands/hvals + /// Adds ping to the request, see https://redis.io/commands/hvals void hvals( std::string_view key) { resp3::assemble(payload, "HVALS", {key}); commands.push(command::hvals); } - /// Adds ping to the pipeline, see https://redis.io/commands/hget + /// Adds ping to the request, see https://redis.io/commands/hget void hget(std::string_view key, std::string_view field) { auto par = {field}; @@ -404,7 +404,7 @@ public: commands.push(command::hget); } - /// Adds ping to the pipeline, see https://redis.io/commands/hmget + /// Adds ping to the request, see https://redis.io/commands/hmget void hmget( std::string_view key, std::initializer_list fields) @@ -418,7 +418,7 @@ public: commands.push(command::hmget); } - /// Adds ping to the pipeline, see https://redis.io/commands/hdel + /// Adds ping to the request, see https://redis.io/commands/hdel void hdel(std::string_view key, std::initializer_list fields) @@ -433,7 +433,7 @@ public: commands.push(command::hdel); } - /// Adds ping to the pipeline, see https://redis.io/commands/expire + /// Adds ping to the request, see https://redis.io/commands/expire void expire(std::string_view key, int secs) { auto const str = std::to_string(secs); @@ -442,7 +442,7 @@ public: commands.push(command::expire); } - /// Adds ping to the pipeline, see https://redis.io/commands/zadd + /// Adds ping to the request, see https://redis.io/commands/zadd void zadd(std::string_view key, int score, std::string_view value) { auto const score_str = std::to_string(score); @@ -451,7 +451,7 @@ public: commands.push(command::zadd); } - /// Adds ping to the pipeline, see https://redis.io/commands/zadd + /// Adds ping to the request, see https://redis.io/commands/zadd template void zadd(std::initializer_list key, Range const& r) { @@ -459,7 +459,7 @@ public: commands.push(command::zadd); } - /// Adds ping to the pipeline, see https://redis.io/commands/zrange + /// Adds ping to the request, see https://redis.io/commands/zrange void zrange(std::string_view key, int min = 0, int max = -1) { auto const min_str = std::to_string(min); @@ -470,7 +470,7 @@ public: commands.push(command::zrange); } - /// Adds ping to the pipeline, see https://redis.io/commands/zrangebyscore + /// Adds ping to the request, see https://redis.io/commands/zrangebyscore void zrangebyscore(std::string_view key, int min, int max) { auto max_str = std::string {"inf"}; @@ -483,7 +483,7 @@ public: commands.push(command::zrangebyscore); } - /// Adds ping to the pipeline, see https://redis.io/commands/zremrangebyscore + /// Adds ping to the request, see https://redis.io/commands/zremrangebyscore void zremrangebyscore( std::string_view key, @@ -495,7 +495,7 @@ public: commands.push(command::zremrangebyscore); } - /// Adds ping to the pipeline, see https://redis.io/commands/lrange + /// Adds ping to the request, see https://redis.io/commands/lrange void lrange(std::string_view key, int min = 0, int max = -1) { auto const min_str = std::to_string(min); @@ -505,7 +505,7 @@ public: commands.push(command::lrange); } - /// Adds ping to the pipeline, see https://redis.io/commands/ltrim + /// Adds ping to the request, see https://redis.io/commands/ltrim void ltrim(std::string_view key, int min = 0, int max = -1) { auto const min_str = std::to_string(min); @@ -516,21 +516,21 @@ public: } // TODO: Overload for vector del. - /// Adds ping to the pipeline, see https://redis.io/commands/del + /// Adds ping to the request, see https://redis.io/commands/del void del(std::string_view key) { resp3::assemble(payload, "DEL", key); commands.push(command::del); } - /// Adds ping to the pipeline, see https://redis.io/commands/llen + /// Adds ping to the request, see https://redis.io/commands/llen void llen(std::string_view key) { resp3::assemble(payload, "LLEN", key); commands.push(command::llen); } - /// Adds ping to the pipeline, see https://redis.io/commands/sadd + /// Adds ping to the request, see https://redis.io/commands/sadd template void sadd(std::string_view key, Iter begin, Iter end) { @@ -538,7 +538,7 @@ public: commands.push(command::sadd); } - /// Adds ping to the pipeline, see https://redis.io/commands/sadd + /// Adds ping to the request, see https://redis.io/commands/sadd template void sadd(std::string_view key, Range const& r) { @@ -547,28 +547,28 @@ public: sadd(key, cbegin(r), cend(r)); } - /// Adds ping to the pipeline, see https://redis.io/commands/smembers + /// Adds ping to the request, see https://redis.io/commands/smembers void smembers(std::string_view key) { resp3::assemble(payload, "SMEMBERS", key); commands.push(command::smembers); } - /// Adds ping to the pipeline, see https://redis.io/commands/scard + /// Adds ping to the request, see https://redis.io/commands/scard void scard(std::string_view key) { resp3::assemble(payload, "SCARD", key); commands.push(command::scard); } - /// Adds ping to the pipeline, see https://redis.io/commands/scard + /// Adds ping to the request, see https://redis.io/commands/scard void scard(std::string_view key, std::initializer_list l) { resp3::assemble(payload, "SDIFF", {key}, std::cbegin(l), std::cend(l)); commands.push(command::scard); } - /// Adds ping to the pipeline, see https://redis.io/commands/client_id + /// Adds ping to the request, see https://redis.io/commands/client_id void client_id(std::string_view parameters) { resp3::assemble(payload, "CLIENT ID", {parameters}); diff --git a/include/aedis/response_buffers.hpp b/include/aedis/response.hpp similarity index 80% rename from include/aedis/response_buffers.hpp rename to include/aedis/response.hpp index 00d5728d..2354a5dc 100644 --- a/include/aedis/response_buffers.hpp +++ b/include/aedis/response.hpp @@ -11,13 +11,13 @@ namespace aedis { -struct response_buffers { - resp3::transaction transaction; +struct response { resp3::array array; - resp3::array push; - resp3::set set; - resp3::map map; - resp3::array attribute; + resp3::flat_array flat_array; + resp3::flat_array flat_push; + resp3::flat_set flat_set; + resp3::flat_map flat_map; + resp3::flat_array flat_attribute; resp3::simple_string simple_string; resp3::simple_error simple_error; resp3::number number; diff --git a/include/aedis/response_adapters.hpp b/include/aedis/response_adapter.hpp similarity index 69% rename from include/aedis/response_adapters.hpp rename to include/aedis/response_adapter.hpp index a3019883..f0482465 100644 --- a/include/aedis/response_adapters.hpp +++ b/include/aedis/response_adapter.hpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -39,7 +39,7 @@ inline void from_string_view(std::string_view s, std::string& r) { r = s; } -struct response_ignore : response_adapter_base { +struct ignore_adapter : response_adapter_base { void on_simple_string(std::string_view s) override {} void on_simple_error(std::string_view s) override {} void on_number(std::string_view s) override {} @@ -60,11 +60,11 @@ struct response_ignore : response_adapter_base { // This response type is able to deal with recursive redis responses // as in a transaction for example. -class response_tree: public response_adapter_base { +class array_adapter: public response_adapter_base { public: - resp3::transaction* result; + resp3::array* result; - response_tree(resp3::transaction* p) : result(p) {} + array_adapter(resp3::array* p) : result(p) {} private: int depth_ = 0; @@ -94,11 +94,11 @@ private: } public: - void select_array(int n) override {add_aggregate(n, resp3::type::array);} - void select_push(int n) override {add_aggregate(n, resp3::type::push);} - void select_set(int n) override {add_aggregate(n, resp3::type::set);} - void select_map(int n) override {add_aggregate(n, resp3::type::map);} - void select_attribute(int n) override {add_aggregate(n, resp3::type::attribute);} + void select_array(int n) override {add_aggregate(n, resp3::type::flat_array);} + void select_push(int n) override {add_aggregate(n, resp3::type::flat_push);} + void select_set(int n) override {add_aggregate(n, resp3::type::flat_set);} + void select_map(int n) override {add_aggregate(n, resp3::type::flat_map);} + void select_attribute(int n) override {add_aggregate(n, resp3::type::flat_attribute);} void on_simple_string(std::string_view s) override { add(s, resp3::type::simple_string); } void on_simple_error(std::string_view s) override { add(s, resp3::type::simple_error); } @@ -116,91 +116,91 @@ public: void pop() override { --depth_; } }; -struct response_number : public response_adapter_base { +struct number_adapter : public response_adapter_base { resp3::number* result = nullptr; - response_number(resp3::number* p) : result(p) {} + number_adapter(resp3::number* p) : result(p) {} void on_number(std::string_view s) override { from_string_view(s, *result); } }; -struct response_blob_string : public response_adapter_base { +struct blob_string_adapter : public response_adapter_base { resp3::blob_string* result = nullptr; - response_blob_string(resp3::blob_string* p) : result(p) {} + blob_string_adapter(resp3::blob_string* p) : result(p) {} void on_blob_string(std::string_view s) override { from_string_view(s, *result); } }; -struct response_blob_error : public response_adapter_base { +struct blob_error_adapter : public response_adapter_base { resp3::blob_error* result = nullptr; - response_blob_error(resp3::blob_error* p) : result(p) {} + blob_error_adapter(resp3::blob_error* p) : result(p) {} void on_blob_error(std::string_view s) override { from_string_view(s, *result); } }; -struct response_simple_string : public response_adapter_base { +struct simple_string_adapter : public response_adapter_base { resp3::simple_string* result = nullptr; - response_simple_string(resp3::simple_string* p) : result(p) {} + simple_string_adapter(resp3::simple_string* p) : result(p) {} void on_simple_string(std::string_view s) override { *result = s; } }; -struct response_simple_error : public response_adapter_base { +struct simple_error_adapter : public response_adapter_base { resp3::simple_error* result = nullptr; - response_simple_error(resp3::simple_error* p) : result(p) {} + simple_error_adapter(resp3::simple_error* p) : result(p) {} void on_simple_error(std::string_view s) override { *result = s; } }; -struct response_big_number : public response_adapter_base { +struct big_number_adapter : public response_adapter_base { resp3::big_number* result = nullptr; - response_big_number(resp3::big_number* p) : result(p) {} + big_number_adapter(resp3::big_number* p) : result(p) {} void on_big_number(std::string_view s) override { from_string_view(s, *result); } }; -struct response_double : public response_adapter_base { +struct doublean_adapter : public response_adapter_base { resp3::doublean* result = nullptr; - response_double(resp3::doublean* p) : result(p) {} + doublean_adapter(resp3::doublean* p) : result(p) {} void on_double(std::string_view s) override { *result = s; } }; -struct response_verbatim_string : public response_adapter_base { +struct verbatim_string_adapter : public response_adapter_base { resp3::verbatim_string* result = nullptr; - response_verbatim_string(resp3::verbatim_string* p) : result(p) {} + verbatim_string_adapter(resp3::verbatim_string* p) : result(p) {} void on_verbatim_string(std::string_view s) override { from_string_view(s, *result); } }; -struct response_streamed_string_part : public response_adapter_base { +struct streamed_string_part_adapter : public response_adapter_base { resp3::streamed_string_part* result = nullptr; - response_streamed_string_part(resp3::streamed_string_part* p) : result(p) {} + streamed_string_part_adapter(resp3::streamed_string_part* p) : result(p) {} void on_streamed_string_part(std::string_view s) override { *result += s; } }; -struct response_bool : public response_adapter_base { +struct boolean_adapter : public response_adapter_base { resp3::boolean* result = nullptr; - response_bool(resp3::boolean* p) : result(p) {} + boolean_adapter(resp3::boolean* p) : result(p) {} void on_bool(std::string_view s) override { @@ -210,11 +210,11 @@ struct response_bool : public response_adapter_base { }; template -struct response_basic_array : response_adapter_base { +struct basic_flat_array_adapter : response_adapter_base { int i = 0; - resp3::basic_array* result = nullptr; + resp3::basic_flat_array* result = nullptr; - response_basic_array(resp3::basic_array* p) : result(p) {} + basic_flat_array_adapter(resp3::basic_flat_array* p) : result(p) {} void add(std::string_view s = {}) { @@ -247,14 +247,14 @@ struct response_basic_array : response_adapter_base { void on_streamed_string_part(std::string_view s = {}) override { add(s); } }; -using response_array = response_basic_array; -using response_array_int = response_basic_array; -using response_push = response_basic_array; +using flat_array_adapter = basic_flat_array_adapter; +using flat_array_int_adapter = basic_flat_array_adapter; +using flat_push_adapter = basic_flat_array_adapter; -struct response_map : response_adapter_base { - resp3::map* result = nullptr; +struct flat_map_adapter : response_adapter_base { + resp3::flat_map* result = nullptr; - response_map(resp3::map* p) : result(p) {} + flat_map_adapter(resp3::flat_map* p) : result(p) {} void add(std::string_view s = {}) { @@ -278,10 +278,10 @@ struct response_map : response_adapter_base { void on_blob_string(std::string_view s = {}) override { add(s); } }; -struct response_set : response_adapter_base { - resp3::set* result = nullptr; +struct flat_set_adapter : response_adapter_base { + resp3::flat_set* result = nullptr; - response_set(resp3::set* p) : result(p) {} + flat_set_adapter(resp3::flat_set* p) : result(p) {} void add(std::string_view s = {}) { @@ -301,43 +301,46 @@ struct response_set : response_adapter_base { void on_blob_string(std::string_view s = {}) override { add(s); } }; -struct response_adapters { - response_tree resp_transaction; - response_array resp_array; - response_push resp_push; - response_set resp_set; - response_map resp_map; - response_array resp_attribute; - response_simple_string resp_simple_string; - response_simple_error resp_simple_error; - response_number resp_number; - response_double resp_double; - response_bool resp_boolean; - response_big_number resp_big_number; - response_blob_string resp_blob_string; - response_blob_error resp_blob_error; - response_verbatim_string resp_verbatim_string; - response_streamed_string_part resp_streamed_string_part; - response_ignore resp_ignore; +struct response_adapter { + array_adapter array; + flat_array_adapter flat_array; + flat_push_adapter flat_push; + flat_set_adapter flat_set; + flat_map_adapter flat_map; + flat_array_adapter flat_attribute; + simple_string_adapter simple_string; + simple_error_adapter simple_error; + number_adapter number; + doublean_adapter doublean; + boolean_adapter boolean; + big_number_adapter big_number; + blob_string_adapter blob_string; + blob_error_adapter blob_error; + verbatim_string_adapter verbatim_string; + streamed_string_part_adapter streamed_string_part; + ignore_adapter resp_ignore; - response_adapters(response_buffers& buf) - : resp_transaction{&buf.transaction} - , resp_array{&buf.array} - , resp_push{&buf.push} - , resp_set{&buf.set} - , resp_map{&buf.map} - , resp_attribute{&buf.attribute} - , resp_simple_string{&buf.simple_string} - , resp_simple_error{&buf.simple_error} - , resp_number{&buf.number} - , resp_double{&buf.doublean} - , resp_boolean{&buf.boolean} - , resp_big_number{&buf.big_number} - , resp_blob_string{&buf.blob_string} - , resp_blob_error{&buf.blob_error} - , resp_verbatim_string{&buf.verbatim_string} - , resp_streamed_string_part{&buf.streamed_string_part} + response_adapter(response& resp) + : array{&resp.array} + , flat_array{&resp.flat_array} + , flat_push{&resp.flat_push} + , flat_set{&resp.flat_set} + , flat_map{&resp.flat_map} + , flat_attribute{&resp.flat_attribute} + , simple_string{&resp.simple_string} + , simple_error{&resp.simple_error} + , number{&resp.number} + , doublean{&resp.doublean} + , boolean{&resp.boolean} + , big_number{&resp.big_number} + , blob_string{&resp.blob_string} + , blob_error{&resp.blob_error} + , verbatim_string{&resp.verbatim_string} + , streamed_string_part{&resp.streamed_string_part} { } }; +response_adapter_base* +select_adapter(response_adapter& adapter, resp3::type t, command cmd); + } // aedis diff --git a/include/aedis/response_adapter_base.hpp b/include/aedis/response_adapter_base.hpp index e08fa07b..99500a40 100644 --- a/include/aedis/response_adapter_base.hpp +++ b/include/aedis/response_adapter_base.hpp @@ -7,31 +7,28 @@ #pragma once -#include #include -#include - namespace aedis { struct response_adapter_base { virtual void pop() {} - virtual void on_simple_string(std::string_view s) { throw std::runtime_error("on_simple_string: Has not been overridden."); } - virtual void on_simple_error(std::string_view s) { throw std::runtime_error("on_simple_error: Has not been overridden."); } - virtual void on_number(std::string_view s) { throw std::runtime_error("on_number: Has not been overridden."); } - virtual void on_double(std::string_view s) { throw std::runtime_error("on_double: Has not been overridden."); } - virtual void on_null() { throw std::runtime_error("on_null: Has not been overridden."); } - virtual void on_bool(std::string_view s) { throw std::runtime_error("on_bool: Has not been overridden."); } - virtual void on_big_number(std::string_view s) { throw std::runtime_error("on_big_number: Has not been overridden."); } - virtual void on_verbatim_string(std::string_view s = {}) { throw std::runtime_error("on_verbatim_string: Has not been overridden."); } - virtual void on_blob_string(std::string_view s = {}) { throw std::runtime_error("on_blob_string: Has not been overridden."); } - virtual void on_blob_error(std::string_view s = {}) { throw std::runtime_error("on_blob_error: Has not been overridden."); } - virtual void on_streamed_string_part(std::string_view s = {}) { throw std::runtime_error("on_streamed_string_part: Has not been overridden."); } - virtual void select_array(int n) { throw std::runtime_error("select_array: Has not been overridden."); } - virtual void select_set(int n) { throw std::runtime_error("select_set: Has not been overridden."); } - virtual void select_map(int n) { throw std::runtime_error("select_map: Has not been overridden."); } - virtual void select_push(int n) { throw std::runtime_error("select_push: Has not been overridden."); } - virtual void select_attribute(int n) { throw std::runtime_error("select_attribute: Has not been overridden."); } + virtual void on_simple_string(std::string_view s) { assert(false); } + virtual void on_simple_error(std::string_view s) { assert(false); } + virtual void on_number(std::string_view s) { assert(false); } + virtual void on_double(std::string_view s) { assert(false); } + virtual void on_null() { assert(false); } + virtual void on_bool(std::string_view s) { assert(false); } + virtual void on_big_number(std::string_view s) { assert(false); } + virtual void on_verbatim_string(std::string_view s = {}) { assert(false); } + virtual void on_blob_string(std::string_view s = {}) { assert(false); } + virtual void on_blob_error(std::string_view s = {}) { assert(false); } + virtual void on_streamed_string_part(std::string_view s = {}) { assert(false); } + virtual void select_array(int n) { assert(false); } + virtual void select_set(int n) { assert(false); } + virtual void select_map(int n) { assert(false); } + virtual void select_push(int n) { assert(false); } + virtual void select_attribute(int n) { assert(false); } virtual ~response_adapter_base() {} }; diff --git a/include/aedis/type.hpp b/include/aedis/type.hpp index d4750ba3..6096e423 100644 --- a/include/aedis/type.hpp +++ b/include/aedis/type.hpp @@ -17,10 +17,11 @@ namespace aedis { namespace resp3 { enum class type { array -, push -, set -, map -, attribute +, flat_array +, flat_push +, flat_set +, flat_map +, flat_attribute , simple_string , simple_error , number @@ -32,28 +33,25 @@ enum class type , verbatim_string , blob_string , streamed_string_part -, transaction // Not from resp3. TODO: Perhaps rename to array and array to flat_array? , invalid }; type to_type(char c); -// TODO: Move everything below to namespace resp3. - template -using basic_array = std::vector; +using basic_flat_array = std::vector; -/// RESP3 array type. -using array = basic_array; -using array_int = basic_array; +/// RESP3 flat array types. +using flat_array = basic_flat_array; +using flat_array_int = basic_flat_array; -using push = std::vector; +using flat_push = std::vector; /// RESP3 map type. -using map = std::vector; +using flat_map = std::vector; /// RESP3 set type. -using set = std::vector; +using flat_set = std::vector; using number = long long int; using boolean = bool; @@ -66,7 +64,7 @@ using big_number = std::string; using verbatim_string = std::string; using streamed_string_part = std::string; -struct transaction_item { +struct node { int depth; resp3::type type; int expected_size = -1; @@ -74,7 +72,7 @@ struct transaction_item { std::vector value; }; -using transaction = std::vector; +using array = std::vector; } // resp3 } // aedis diff --git a/include/aedis/utils.hpp b/include/aedis/utils.hpp index fe3f0368..cd57d6ea 100644 --- a/include/aedis/utils.hpp +++ b/include/aedis/utils.hpp @@ -11,7 +11,7 @@ #include "type.hpp" #include "command.hpp" -#include "response_buffers.hpp" +#include "response.hpp" namespace aedis { diff --git a/include/aedis/version.hpp b/include/aedis/version.hpp index c2d9d075..5c101755 100644 --- a/include/aedis/version.hpp +++ b/include/aedis/version.hpp @@ -5,5 +5,5 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#define AEDIS_VERSION 3 +#define AEDIS_VERSION 4 diff --git a/include/aedis/write.hpp b/include/aedis/write.hpp index a61c3e2f..9ac98b44 100644 --- a/include/aedis/write.hpp +++ b/include/aedis/write.hpp @@ -10,20 +10,20 @@ #include #include -#include +#include #include #include namespace aedis { -bool prepare_queue(std::queue& reqs); +bool prepare_next(std::queue& reqs); template std::size_t write( SyncWriteStream& stream, - pipeline& req, + request& req, boost::system::error_code& ec) { static_assert(boost::beast::is_sync_write_stream::value, @@ -35,7 +35,7 @@ write( template std::size_t write( SyncWriteStream& stream, - pipeline& req) + request& req) { static_assert(boost::beast::is_sync_write_stream::value, "SyncWriteStream type requirements not met"); @@ -49,12 +49,12 @@ std::size_t write( return bytes_transferred; } -/** Asynchronously writes one or more command pipelines on the stream. +/** Asynchronously writes one or more requests on the stream. */ template struct write_some_op { AsyncWriteStream& stream; - std::queue& pipelines; + std::queue& requests; net::coroutine coro = net::coroutine(); void @@ -65,26 +65,26 @@ struct write_some_op { { reenter (coro) { do { - assert(!std::empty(pipelines)); - assert(!std::empty(pipelines.front().payload)); + assert(!std::empty(requests)); + assert(!std::empty(requests.front().payload)); yield async_write( stream, - net::buffer(pipelines.front().payload), + net::buffer(requests.front().payload), std::move(self)); if (ec) break; - pipelines.front().sent = true; + requests.front().sent = true; - if (std::empty(pipelines.front().commands)) { + if (std::empty(requests.front().commands)) { // We only pop when all commands in the pipeline has push // responses like subscribe, otherwise, pop is done when the // response arrives. - pipelines.pop(); + requests.pop(); } - } while (!std::empty(pipelines) && std::empty(pipelines.front().commands)); + } while (!std::empty(requests) && std::empty(requests.front().commands)); self.complete(ec); } @@ -97,13 +97,13 @@ template< auto async_write_some( AsyncWriteStream& stream, - std::queue& pipelines, + std::queue& requests, CompletionToken&& token) { return net::async_compose< CompletionToken, void(boost::system::error_code)>( - write_some_op{stream, pipelines}, + write_some_op{stream, requests}, token, stream); } diff --git a/tests/general.cpp b/tests/general.cpp index ceafc027..abfed01a 100644 --- a/tests/general.cpp +++ b/tests/general.cpp @@ -45,7 +45,7 @@ struct test_general_fill { std::vector list_ {1 ,2, 3, 4, 5, 6}; std::string set_ {"aaa"}; - void operator()(pipeline& p) const + void operator()(request& p) const { p.flushall(); p.rpush("a", list_); @@ -107,30 +107,30 @@ test_general(net::ip::tcp::resolver::results_type const& res) std::string buffer; - std::queue pipelines; - pipelines.push({}); - pipelines.back().hello("3"); + std::queue requests; + requests.push({}); + requests.back().hello("3"); test_general_fill filler; - auto tmp = net::buffer(pipelines.back().payload); + auto tmp = net::buffer(requests.back().payload); co_await async_write(socket, tmp, net::use_awaitable); int push_counter = 0; - response_buffers bufs; + response resp; for (;;) { - auto const event = co_await async_consume(socket, buffer, bufs, pipelines); + auto const event = co_await async_consume(socket, buffer, resp, requests); switch (event.second) { case resp3::type::simple_string: { switch (event.first) { - case command::multi: check_equal(bufs.simple_string, {"OK"}, "multi"); break; - case command::ping: check_equal(bufs.simple_string, {"QUEUED"}, "ping"); break; - case command::set: check_equal(bufs.simple_string, {"OK"}, "set"); break; - case command::quit: check_equal(bufs.simple_string, {"OK"}, "quit"); break; - case command::flushall: check_equal(bufs.simple_string, {"OK"}, "flushall"); break; - case command::ltrim: check_equal(bufs.simple_string, {"OK"}, "ltrim"); break; + case command::multi: check_equal(resp.simple_string, {"OK"}, "multi"); break; + case command::ping: check_equal(resp.simple_string, {"QUEUED"}, "ping"); break; + case command::set: check_equal(resp.simple_string, {"OK"}, "set"); break; + case command::quit: check_equal(resp.simple_string, {"OK"}, "quit"); break; + case command::flushall: check_equal(resp.simple_string, {"OK"}, "flushall"); break; + case command::ltrim: check_equal(resp.simple_string, {"OK"}, "ltrim"); break; default: { std::cout << "Error: " << event.first << " " << event.second << std::endl; } @@ -138,18 +138,18 @@ test_general(net::ip::tcp::resolver::results_type const& res) } break; case resp3::type::number: { switch (event.first) { - case command::append: check_equal(bufs.number, 4LL, "append"); break; - case command::hset: check_equal(bufs.number, 2LL, "hset"); break; - case command::rpush: check_equal(bufs.number, (resp3::number)std::size(filler.list_), "rpush (value)"); break; - case command::del: check_equal(bufs.number, 1LL, "del"); break; - case command::llen: check_equal(bufs.number, 6LL, "llen"); break; - case command::incr: check_equal(bufs.number, 1LL, "incr"); break; - case command::publish: check_equal(bufs.number, 1LL, "publish"); break; - case command::hincrby: check_equal(bufs.number, 10LL, "hincrby"); break; - case command::zadd: check_equal(bufs.number, 1LL, "zadd"); break; - case command::sadd: check_equal(bufs.number, 3LL, "sadd"); break; - case command::hdel: check_equal(bufs.number, 2LL, "hdel"); break; - case command::zremrangebyscore: check_equal(bufs.number, 1LL, "zremrangebyscore"); break; + case command::append: check_equal(resp.number, 4LL, "append"); break; + case command::hset: check_equal(resp.number, 2LL, "hset"); break; + case command::rpush: check_equal(resp.number, (resp3::number)std::size(filler.list_), "rpush (value)"); break; + case command::del: check_equal(resp.number, 1LL, "del"); break; + case command::llen: check_equal(resp.number, 6LL, "llen"); break; + case command::incr: check_equal(resp.number, 1LL, "incr"); break; + case command::publish: check_equal(resp.number, 1LL, "publish"); break; + case command::hincrby: check_equal(resp.number, 10LL, "hincrby"); break; + case command::zadd: check_equal(resp.number, 1LL, "zadd"); break; + case command::sadd: check_equal(resp.number, 3LL, "sadd"); break; + case command::hdel: check_equal(resp.number, 2LL, "hdel"); break; + case command::zremrangebyscore: check_equal(resp.number, 1LL, "zremrangebyscore"); break; default: { std::cout << "Error: " << event.first << " " << event.second << std::endl; } @@ -157,21 +157,21 @@ test_general(net::ip::tcp::resolver::results_type const& res) } break; case resp3::type::blob_string: { switch (event.first) { - case command::get: check_equal(bufs.blob_string, filler.set_, "get"); break; - case command::hget: check_equal(bufs.blob_string, std::string{"value2"}, "hget"); break; - case command::lpop: check_equal(bufs.blob_string, {"3"}, "lpop"); break; + case command::get: check_equal(resp.blob_string, filler.set_, "get"); break; + case command::hget: check_equal(resp.blob_string, std::string{"value2"}, "hget"); break; + case command::lpop: check_equal(resp.blob_string, {"3"}, "lpop"); break; default: { std::cout << "Error: " << event.first << " " << event.second << std::endl; } } } break; - case resp3::type::push: { + case resp3::type::flat_push: { switch (push_counter) { case 0: - check_equal(bufs.push, {"subscribe", "channel", "1"}, "push (value1)"); + check_equal(resp.flat_push, {"subscribe", "channel", "1"}, "push (value1)"); break; case 1: - check_equal(bufs.push, {"message", "channel", "message"}, "push (value2)"); + check_equal(resp.flat_push, {"message", "channel", "message"}, "push (value2)"); break; defalt: std::cout @@ -182,54 +182,54 @@ test_general(net::ip::tcp::resolver::results_type const& res) } ++push_counter; } break; - case resp3::type::array: { + case resp3::type::flat_array: { switch (event.first) { - case command::lrange: check_equal(bufs.array, {"1", "2", "3", "4", "5", "6"}, "lrange"); break; - case command::hvals: check_equal(bufs.array, {"value1", "value2"}, "hvals"); break; - case command::zrange: check_equal(bufs.array, {"Marcelo"}, "hvals"); break; - case command::zrangebyscore: check_equal(bufs.array, {"Marcelo"}, "zrangebyscore"); break; - case command::lpop: check_equal(bufs.array, {"4", "5"}, "lpop"); break; + case command::lrange: check_equal(resp.flat_array, {"1", "2", "3", "4", "5", "6"}, "lrange"); break; + case command::hvals: check_equal(resp.flat_array, {"value1", "value2"}, "hvals"); break; + case command::zrange: check_equal(resp.flat_array, {"Marcelo"}, "hvals"); break; + case command::zrangebyscore: check_equal(resp.flat_array, {"Marcelo"}, "zrangebyscore"); break; + case command::lpop: check_equal(resp.flat_array, {"4", "5"}, "lpop"); break; case command::exec: // TODO: Remove resp3::type::transaction? It is not resp3 // native. - check_equal_number(event.second, resp3::type::array, "exec (type)"); - check_equal(std::size(bufs.transaction), 2lu, "exec (size)"); + check_equal_number(event.second, resp3::type::flat_array, "exec (type)"); + check_equal(std::size(resp.array), 2lu, "exec (size)"); - check_equal(bufs.transaction[0].cmd, command::unknown, "transaction ping (command)"); - check_equal(bufs.transaction[0].depth, 1, "transaction (depth)"); - check_equal(bufs.transaction[0].type, resp3::type::simple_string, "transaction (type)"); - check_equal(bufs.transaction[0].expected_size, 1, "transaction (size)"); + check_equal(resp.array[0].cmd, command::unknown, "transaction ping (command)"); + check_equal(resp.array[0].depth, 1, "transaction (depth)"); + check_equal(resp.array[0].type, resp3::type::simple_string, "transaction (type)"); + check_equal(resp.array[0].expected_size, 1, "transaction (size)"); - check_equal(bufs.transaction[1].cmd, command::unknown, "transaction ping (command)"); - check_equal(bufs.transaction[1].depth, 1, "transaction (depth)"); - check_equal(bufs.transaction[1].type, resp3::type::simple_string, "transaction (typ)e"); - check_equal(bufs.transaction[1].expected_size, 1, "transaction (size)"); + check_equal(resp.array[1].cmd, command::unknown, "transaction ping (command)"); + check_equal(resp.array[1].depth, 1, "transaction (depth)"); + check_equal(resp.array[1].type, resp3::type::simple_string, "transaction (typ)e"); + check_equal(resp.array[1].expected_size, 1, "transaction (size)"); - bufs.transaction.clear(); + resp.array.clear(); break; default: { std::cout << "Error: " << event.first << " " << event.second << std::endl; } } } break; - case resp3::type::map: { + case resp3::type::flat_map: { switch (event.first) { - case command::hgetall: check_equal(bufs.map, {"field1", "value1", "field2", "value2"}, "hgetall (value)"); break; + case command::hgetall: check_equal(resp.flat_map, {"field1", "value1", "field2", "value2"}, "hgetall (value)"); break; case command::hello: { - auto const empty = prepare_queue(pipelines); - filler(pipelines.back()); + auto const empty = prepare_next(requests); + filler(requests.back()); if (empty) - co_await async_write_some(socket, pipelines, net::use_awaitable); + co_await async_write_some(socket, requests, net::use_awaitable); } break; default: { std::cout << "Error: " << event.first << " " << event.second << std::endl; } } } break; - case resp3::type::set: { + case resp3::type::flat_set: { switch (event.first) { - case command::smembers: check_equal(bufs.set, {"1", "2", "3"}, "smembers (value)"); break; + case command::smembers: check_equal(resp.flat_set, {"1", "2", "3"}, "smembers (value)"); break; default: { std::cout << "Error: " << event.first << " " << event.second << std::endl; } @@ -240,10 +240,10 @@ test_general(net::ip::tcp::resolver::results_type const& res) } } - bufs.blob_string.clear(); - bufs.push.clear(); - bufs.map.clear(); - bufs.set.clear(); + resp.blob_string.clear(); + resp.flat_push.clear(); + resp.flat_map.clear(); + resp.flat_set.clear(); } } @@ -254,7 +254,7 @@ test_list(net::ip::tcp::resolver::results_type const& results) { std::vector list {1 ,2, 3, 4, 5, 6}; - pipeline p; + request p; p.hello("3"); p.flushall(); p.rpush("a", list); @@ -271,55 +271,55 @@ test_list(net::ip::tcp::resolver::results_type const& results) std::string buf; { // hello - response_ignore res; + ignore_adapter res; co_await async_read_one_impl(socket, buf, res); } { // flushall resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, {"OK"}, "flushall"); } { // rpush resp3::number buffer; - response_number res{&buffer}; + number_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, (long long int)6, "rpush"); } { // lrange - resp3::array_int buffer; - response_basic_array res{&buffer}; + resp3::flat_array_int buffer; + basic_flat_array_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, list, "lrange-1"); } { // lrange - resp3::array_int buffer; - response_basic_array res{&buffer}; + resp3::flat_array_int buffer; + basic_flat_array_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, std::vector{3, 4, 5}, "lrange-2"); } { // ltrim resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, {"OK"}, "ltrim"); } { // lpop. Why a blob string instead of a number? resp3::blob_string buffer; - response_blob_string res{&buffer}; + blob_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, {"3"}, "lpop"); } { // quit resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, {"OK"}, "quit"); } @@ -341,7 +341,7 @@ test_set(net::ip::tcp::resolver::results_type const& results) tcp_socket socket {ex}; co_await async_connect(socket, results); - pipeline p; + request p; p.hello("3"); p.flushall(); p.set("s", {test_bulk1}); @@ -356,56 +356,56 @@ test_set(net::ip::tcp::resolver::results_type const& results) std::string buf; { // hello, flushall - response_ignore res; + ignore_adapter res; co_await async_read_one_impl(socket, buf, res); co_await async_read_one_impl(socket, buf, res); } { // set resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, {"OK"}, "set1"); } { // get resp3::blob_string buffer; - response_blob_string res{&buffer}; + blob_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, test_bulk1, "get1"); } { // set resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, {"OK"}, "set1"); } { // get resp3::blob_string buffer; - response_blob_string res{&buffer}; + blob_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, test_bulk2, "get2"); } { // set resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, {"OK"}, "set3"); } { // get resp3::blob_string buffer; - response_blob_string res{&buffer}; + blob_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, std::string {}, "get3"); } { // quit resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(socket, buf, res); check_equal(buffer, {"OK"}, "quit"); } @@ -427,7 +427,7 @@ net::awaitable test_simple_string() std::string cmd {"+OK\r\n"}; test_tcp_socket ts {cmd}; resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"OK"}, "simple_string"); //check_equal(res.attribute.value, {}, "simple_string (empty attribute)"); @@ -438,7 +438,7 @@ net::awaitable test_simple_string() std::string cmd {"+\r\n"}; test_tcp_socket ts {cmd}; resp3::simple_string buffer; - response_simple_string res{&buffer}; + simple_string_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {}, "simple_string (empty)"); //check_equal(res.attribute.value, {}, "simple_string (empty attribute)"); @@ -452,7 +452,7 @@ net::awaitable test_simple_string() // cmd += str; // cmd += "\r\n"; // test_tcp_socket ts {cmd}; - // response_simple_string res; + // simple_string_adapter res; // co_await async_read_one_impl(ts, buffer, res); // check_equal(res.result, str, "simple_string (large)"); // //check_equal(res.attribute.value, {}, "simple_string (empty attribute)"); @@ -467,7 +467,7 @@ net::awaitable test_number() std::string cmd {":-3\r\n"}; test_tcp_socket ts {cmd}; resp3::number buffer; - response_number res{&buffer}; + number_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, (long long int)-3, "number (int)"); } @@ -476,7 +476,7 @@ net::awaitable test_number() std::string cmd {":3\r\n"}; test_tcp_socket ts {cmd}; resp3::number buffer; - response_number res{&buffer}; + number_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, (long long int)3, "number (unsigned)"); } @@ -485,7 +485,7 @@ net::awaitable test_number() std::string cmd {":1111111\r\n"}; test_tcp_socket ts {cmd}; resp3::number buffer; - response_number res{&buffer}; + number_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, (long long int)1111111, "number (std::size_t)"); } @@ -498,8 +498,8 @@ net::awaitable test_array() { // String std::string cmd {"*3\r\n$3\r\none\r\n$3\r\ntwo\r\n$5\r\nthree\r\n"}; test_tcp_socket ts {cmd}; - resp3::array buffer; - response_array res{&buffer}; + resp3::flat_array buffer; + flat_array_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"one", "two", "three"}, "array (dynamic)"); } @@ -507,8 +507,8 @@ net::awaitable test_array() { // int std::string cmd {"*3\r\n$1\r\n1\r\n$1\r\n2\r\n$1\r\n3\r\n"}; test_tcp_socket ts {cmd}; - resp3::array_int buffer; - response_array_int res{&buffer}; + resp3::flat_array_int buffer; + flat_array_int_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {1, 2, 3}, "array (int)"); } @@ -516,8 +516,8 @@ net::awaitable test_array() { std::string cmd {"*0\r\n"}; test_tcp_socket ts {cmd}; - resp3::array buffer; - response_array res{&buffer}; + resp3::flat_array buffer; + flat_array_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {}, "array (empty)"); } @@ -531,7 +531,7 @@ net::awaitable test_blob_string() std::string cmd {"$2\r\nhh\r\n"}; test_tcp_socket ts {cmd}; resp3::blob_string buffer; - response_blob_string res{&buffer}; + blob_string_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"hh"}, "blob_string"); } @@ -540,7 +540,7 @@ net::awaitable test_blob_string() std::string cmd {"$26\r\nhhaa\aaaa\raaaaa\r\naaaaaaaaaa\r\n"}; test_tcp_socket ts {cmd}; resp3::blob_string buffer; - response_blob_string res{&buffer}; + blob_string_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"hhaa\aaaa\raaaaa\r\naaaaaaaaaa"}, "blob_string (with separator)"); } @@ -549,7 +549,7 @@ net::awaitable test_blob_string() std::string cmd {"$0\r\n\r\n"}; test_tcp_socket ts {cmd}; resp3::blob_string buffer; - response_blob_string res{&buffer}; + blob_string_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {}, "blob_string (size 0)"); } @@ -563,7 +563,7 @@ net::awaitable test_simple_error() std::string cmd {"-Error\r\n"}; test_tcp_socket ts {cmd}; resp3::simple_error buffer; - response_simple_error res{&buffer}; + simple_error_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"Error"}, "simple_error (message)"); } @@ -577,7 +577,7 @@ net::awaitable test_floating_point() std::string cmd {",1.23\r\n"}; test_tcp_socket ts {cmd}; resp3::doublean buffer; - response_double res{&buffer}; + doublean_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"1.23"}, "double"); } @@ -586,7 +586,7 @@ net::awaitable test_floating_point() std::string cmd {",inf\r\n"}; test_tcp_socket ts {cmd}; resp3::doublean buffer; - response_double res{&buffer}; + doublean_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"inf"}, "double (inf)"); } @@ -595,7 +595,7 @@ net::awaitable test_floating_point() std::string cmd {",-inf\r\n"}; test_tcp_socket ts {cmd}; resp3::doublean buffer; - response_double res{&buffer}; + doublean_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"-inf"}, "double (-inf)"); } @@ -610,7 +610,7 @@ net::awaitable test_boolean() std::string cmd {"#f\r\n"}; test_tcp_socket ts {cmd}; resp3::boolean buffer; - response_bool res{&buffer}; + boolean_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, false, "bool (false)"); } @@ -619,7 +619,7 @@ net::awaitable test_boolean() std::string cmd {"#t\r\n"}; test_tcp_socket ts {cmd}; resp3::boolean buffer; - response_bool res{&buffer}; + boolean_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, true, "bool (true)"); } @@ -633,7 +633,7 @@ net::awaitable test_blob_error() std::string cmd {"!21\r\nSYNTAX invalid syntax\r\n"}; test_tcp_socket ts {cmd}; resp3::blob_error buffer; - response_blob_error res{&buffer}; + blob_error_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"SYNTAX invalid syntax"}, "blob_error (message)"); } @@ -642,7 +642,7 @@ net::awaitable test_blob_error() std::string cmd {"!0\r\n\r\n"}; test_tcp_socket ts {cmd}; resp3::blob_error buffer; - response_blob_error res{&buffer}; + blob_error_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {}, "blob_error (empty message)"); } @@ -656,7 +656,7 @@ net::awaitable test_verbatim_string() std::string cmd {"=15\r\ntxt:Some string\r\n"}; test_tcp_socket ts {cmd}; resp3::verbatim_string buffer; - response_verbatim_string res{&buffer}; + verbatim_string_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"txt:Some string"}, "verbatim_string"); } @@ -665,7 +665,7 @@ net::awaitable test_verbatim_string() std::string cmd {"=0\r\n\r\n"}; test_tcp_socket ts {cmd}; resp3::verbatim_string buffer; - response_verbatim_string res{&buffer}; + verbatim_string_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {}, "verbatim_string (empty)"); } @@ -678,8 +678,8 @@ net::awaitable test_set2() { std::string cmd {"~5\r\n+orange\r\n+apple\r\n+one\r\n+two\r\n+three\r\n"}; test_tcp_socket ts {cmd}; - resp3::set buffer; - response_set res{&buffer}; + resp3::flat_set buffer; + flat_set_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"orange", "apple", "one", "two", "three"}, "set"); } @@ -687,8 +687,8 @@ net::awaitable test_set2() { std::string cmd {"~5\r\n+orange\r\n+apple\r\n+one\r\n+two\r\n+three\r\n"}; test_tcp_socket ts {cmd}; - resp3::set buffer; - response_set res{&buffer}; + resp3::flat_set buffer; + flat_set_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"orange", "apple", "one", "two", "three"}, "set (flat)"); } @@ -696,8 +696,8 @@ net::awaitable test_set2() { std::string cmd {"~0\r\n"}; test_tcp_socket ts {cmd}; - resp3::set buffer; - response_set res{&buffer}; + resp3::flat_set buffer; + flat_set_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {}, "set (empty)"); } @@ -710,8 +710,8 @@ net::awaitable test_map() { std::string cmd {"%7\r\n$6\r\nserver\r\n$5\r\nredis\r\n$7\r\nversion\r\n$5\r\n6.0.9\r\n$5\r\nproto\r\n:3\r\n$2\r\nid\r\n:203\r\n$4\r\nmode\r\n$10\r\nstandalone\r\n$4\r\nrole\r\n$6\r\nmaster\r\n$7\r\nmodules\r\n*0\r\n"}; test_tcp_socket ts {cmd}; - resp3::map buffer; - response_map res{&buffer}; + resp3::flat_map buffer; + flat_map_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"server", "redis", "version", "6.0.9", "proto", "3", "id", "203", "mode", "standalone", "role", "master", "modules"}, "map (flat)"); } @@ -719,8 +719,8 @@ net::awaitable test_map() { std::string cmd {"%0\r\n"}; test_tcp_socket ts {cmd}; - resp3::map buffer; - response_map res{&buffer}; + resp3::flat_map buffer; + flat_map_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {}, "map (flat - empty)"); } @@ -734,7 +734,7 @@ net::awaitable test_streamed_string() std::string cmd {"$?\r\n;4\r\nHell\r\n;5\r\no wor\r\n;1\r\nd\r\n;0\r\n"}; test_tcp_socket ts {cmd}; resp3::streamed_string_part buffer; - response_streamed_string_part res{&buffer}; + streamed_string_part_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {"Hello word"}, "streamed string"); } @@ -742,8 +742,8 @@ net::awaitable test_streamed_string() { std::string cmd {"$?\r\n;0\r\n"}; test_tcp_socket ts {cmd}; - resp3::array buffer; - response_array res{&buffer}; + resp3::flat_array buffer; + flat_array_adapter res{&buffer}; co_await async_read_one_impl(ts, buf, res); check_equal(buffer, {}, "streamed string (empty)"); } @@ -755,7 +755,7 @@ net::awaitable offline() //{ // std::string cmd {"|1\r\n+key-popularity\r\n%2\r\n$1\r\na\r\n,0.1923\r\n$1\r\nb\r\n,0.0012\r\n"}; // test_tcp_socket ts {cmd}; - // response_array res; + // flat_array_adapter res; // co_await async_read_one_impl(ts, buf, res); // check_equal(res.result, {"key-popularity", "a", "0.1923", "b", "0.0012"}, "attribute"); //} @@ -763,7 +763,7 @@ net::awaitable offline() //{ // std::string cmd {">4\r\n+pubsub\r\n+message\r\n+foo\r\n+bar\r\n"}; // test_tcp_socket ts {cmd}; - // response_array res; + // flat_array_adapter res; // co_await async_read_one_impl(ts, buf, res); // check_equal(res.result, {"pubsub", "message", "foo", "bar"}, "push type"); //} @@ -771,7 +771,7 @@ net::awaitable offline() //{ // std::string cmd {">0\r\n"}; // test_tcp_socket ts {cmd}; - // response_array res; + // flat_array_adapter res; // co_await async_read_one_impl(ts, buf, res); // check_equal(res.result, {}, "push type (empty)"); //}