Skip to content

Commit 82430af

Browse files
committed
Make the connection non-generic on the executor type.
1 parent 607946f commit 82430af

14 files changed

+119
-26
lines changed

examples/cpp20_chat_room.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919

2020
namespace net = boost::asio;
2121
using stream_descriptor = net::deferred_t::as_default_on_t<net::posix::stream_descriptor>;
22-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
2322
using signal_set = net::deferred_t::as_default_on_t<net::signal_set>;
2423
using boost::redis::request;
2524
using boost::redis::generic_response;
2625
using boost::redis::config;
26+
using boost::redis::connection;
27+
using boost::redis::ignore;
2728
using net::redirect_error;
2829
using net::use_awaitable;
2930
using boost::system::error_code;
@@ -41,7 +42,7 @@ receiver(std::shared_ptr<connection> conn) -> net::awaitable<void>
4142
while (conn->will_reconnect()) {
4243

4344
// Subscribe to channels.
44-
co_await conn->async_exec(req);
45+
co_await conn->async_exec(req, ignore, net::deferred);
4546

4647
// Loop reading Redis push messages.
4748
for (generic_response resp;;) {
@@ -66,7 +67,7 @@ auto publisher(std::shared_ptr<stream_descriptor> in, std::shared_ptr<connection
6667
auto n = co_await net::async_read_until(*in, net::dynamic_buffer(msg, 1024), "\n");
6768
request req;
6869
req.push("PUBLISH", "channel", msg);
69-
co_await conn->async_exec(req);
70+
co_await conn->async_exec(req, ignore, net::deferred);
7071
msg.erase(0, n);
7172
}
7273
}

examples/cpp20_containers.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using boost::redis::response;
2020
using boost::redis::ignore_t;
2121
using boost::redis::ignore;
2222
using boost::redis::config;
23-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
23+
using boost::redis::connection;
2424

2525
void print(std::map<std::string, std::string> const& cont)
2626
{
@@ -47,7 +47,7 @@ auto store(std::shared_ptr<connection> conn) -> net::awaitable<void>
4747
req.push_range("RPUSH", "rpush-key", vec);
4848
req.push_range("HSET", "hset-key", map);
4949

50-
co_await conn->async_exec(req);
50+
co_await conn->async_exec(req, ignore, net::deferred);
5151
}
5252

5353
auto hgetall(std::shared_ptr<connection> conn) -> net::awaitable<void>
@@ -60,7 +60,7 @@ auto hgetall(std::shared_ptr<connection> conn) -> net::awaitable<void>
6060
response<std::map<std::string, std::string>> resp;
6161

6262
// Executes the request and reads the response.
63-
co_await conn->async_exec(req, resp);
63+
co_await conn->async_exec(req, resp, net::deferred);
6464

6565
print(std::get<0>(resp).value());
6666
}
@@ -81,7 +81,7 @@ auto transaction(std::shared_ptr<connection> conn) -> net::awaitable<void>
8181
response<std::optional<std::vector<int>>, std::optional<std::map<std::string, std::string>>> // exec
8282
> resp;
8383

84-
co_await conn->async_exec(req, resp);
84+
co_await conn->async_exec(req, resp, net::deferred);
8585

8686
print(std::get<0>(std::get<3>(resp).value()).value().value());
8787
print(std::get<1>(std::get<3>(resp).value()).value().value());

examples/cpp20_echo_server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ namespace net = boost::asio;
1818
using tcp_socket = net::deferred_t::as_default_on_t<net::ip::tcp::socket>;
1919
using tcp_acceptor = net::deferred_t::as_default_on_t<net::ip::tcp::acceptor>;
2020
using signal_set = net::deferred_t::as_default_on_t<net::signal_set>;
21-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
2221
using boost::redis::request;
2322
using boost::redis::response;
2423
using boost::redis::config;
2524
using boost::system::error_code;
25+
using boost::redis::connection;
2626
using namespace std::chrono_literals;
2727

2828
auto echo_server_session(tcp_socket socket, std::shared_ptr<connection> conn) -> net::awaitable<void>
@@ -33,7 +33,7 @@ auto echo_server_session(tcp_socket socket, std::shared_ptr<connection> conn) ->
3333
for (std::string buffer;;) {
3434
auto n = co_await net::async_read_until(socket, net::dynamic_buffer(buffer, 1024), "\n");
3535
req.push("PING", buffer);
36-
co_await conn->async_exec(req, resp);
36+
co_await conn->async_exec(req, resp, net::deferred);
3737
co_await net::async_write(socket, net::buffer(std::get<0>(resp).value()));
3838
std::get<0>(resp).value().clear();
3939
req.clear();

examples/cpp20_intro.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ namespace net = boost::asio;
1717
using boost::redis::request;
1818
using boost::redis::response;
1919
using boost::redis::config;
20-
using boost::redis::logger;
21-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
20+
using boost::redis::connection;
2221

2322
// Called from the main function (see main.cpp)
2423
auto co_main(config cfg) -> net::awaitable<void>
@@ -34,7 +33,7 @@ auto co_main(config cfg) -> net::awaitable<void>
3433
response<std::string> resp;
3534

3635
// Executes the request.
37-
co_await conn->async_exec(req, resp);
36+
co_await conn->async_exec(req, resp, net::deferred);
3837
conn->cancel();
3938

4039
std::cout << "PING: " << std::get<0>(resp).value() << std::endl;

examples/cpp20_intro_tls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using boost::redis::request;
1818
using boost::redis::response;
1919
using boost::redis::config;
2020
using boost::redis::logger;
21-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
21+
using boost::redis::connection;
2222

2323
auto verify_certificate(bool, net::ssl::verify_context&) -> bool
2424
{
@@ -45,7 +45,7 @@ auto co_main(config cfg) -> net::awaitable<void>
4545
conn->next_layer().set_verify_mode(net::ssl::verify_peer);
4646
conn->next_layer().set_verify_callback(verify_certificate);
4747

48-
co_await conn->async_exec(req, resp);
48+
co_await conn->async_exec(req, resp, net::deferred);
4949
conn->cancel();
5050

5151
std::cout << "Response: " << std::get<0>(resp).value() << std::endl;

examples/cpp20_json.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using boost::redis::request;
2929
using boost::redis::response;
3030
using boost::redis::ignore_t;
3131
using boost::redis::config;
32-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
32+
using boost::redis::connection;
3333

3434
// Struct that will be stored in Redis using json serialization.
3535
struct user {
@@ -64,7 +64,7 @@ auto co_main(config cfg) -> net::awaitable<void>
6464

6565
response<ignore_t, user> resp;
6666

67-
co_await conn->async_exec(req, resp);
67+
co_await conn->async_exec(req, resp, net::deferred);
6868
conn->cancel();
6969

7070
// Prints the first ping

examples/cpp20_protobuf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using boost::redis::response;
2525
using boost::redis::operation;
2626
using boost::redis::ignore_t;
2727
using boost::redis::config;
28-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
28+
using boost::redis::connection;
2929

3030
// The protobuf type described in examples/person.proto
3131
using tutorial::person;
@@ -76,7 +76,7 @@ net::awaitable<void> co_main(config cfg)
7676
response<ignore_t, person> resp;
7777

7878
// Sends the request and receives the response.
79-
co_await conn->async_exec(req, resp);
79+
co_await conn->async_exec(req, resp, net::deferred);
8080
conn->cancel();
8181

8282
std::cout

examples/cpp20_resolve_with_sentinel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using boost::redis::response;
1919
using boost::redis::ignore_t;
2020
using boost::redis::config;
2121
using boost::redis::address;
22-
using connection = boost::asio::use_awaitable_t<>::as_default_on_t<boost::redis::connection>;
22+
using boost::redis::connection;
2323

2424
auto redir(boost::system::error_code& ec)
2525
{ return net::redirect_error(net::use_awaitable, ec); }

examples/cpp20_streams.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using boost::redis::config;
2525
using boost::redis::generic_response;
2626
using boost::redis::operation;
2727
using boost::redis::request;
28-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
28+
using boost::redis::connection;
2929
using signal_set = net::deferred_t::as_default_on_t<net::signal_set>;
3030

3131
auto stream_reader(std::shared_ptr<connection> conn) -> net::awaitable<void>
@@ -39,7 +39,7 @@ auto stream_reader(std::shared_ptr<connection> conn) -> net::awaitable<void>
3939

4040
for (;;) {
4141
req.push("XREAD", "BLOCK", "0", "STREAMS", "test-topic", stream_id);
42-
co_await conn->async_exec(req, resp);
42+
co_await conn->async_exec(req, resp, net::deferred);
4343

4444
// std::cout << "Response: ";
4545
// for (int i = 0; i < resp->value().size(); ++i) {

examples/cpp20_subscriber.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ using boost::redis::request;
2424
using boost::redis::generic_response;
2525
using boost::redis::logger;
2626
using boost::redis::config;
27+
using boost::redis::ignore;
2728
using boost::system::error_code;
28-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
29+
using boost::redis::connection;
2930
using signal_set = net::deferred_t::as_default_on_t<net::signal_set>;
3031

3132
/* This example will subscribe and read pushes indefinitely.
@@ -54,7 +55,7 @@ receiver(std::shared_ptr<connection> conn) -> net::awaitable<void>
5455
while (conn->will_reconnect()) {
5556

5657
// Reconnect to channels.
57-
co_await conn->async_exec(req);
58+
co_await conn->async_exec(req, ignore, net::deferred);
5859

5960
// Loop reading Redis pushs messages.
6061
for (generic_response resp;;) {

0 commit comments

Comments
 (0)