Skip to content

Commit 3808fec

Browse files
brammzimbres
authored andcommitted
Cleaned up a bit
Removed unused stuff Using request and response as shared_ptrs. Removed (unnecessary?) calls to net::post.
1 parent 607a9e9 commit 3808fec

11 files changed

+17
-11
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ endif()
9595
add_executable(cpp20_streams examples/cpp20_streams.cpp)
9696
target_link_libraries(cpp20_streams common)
9797
target_compile_features(cpp20_streams PUBLIC cxx_std_20)
98-
add_test(cpp20_streams cpp20_streams)
9998
if (MSVC)
10099
target_compile_options(cpp20_streams PRIVATE /bigobj)
101100
target_compile_definitions(cpp20_streams PRIVATE _WIN32_WINNT=0x0601)

examples/cpp20_chat_room.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ auto publisher(std::shared_ptr<stream_descriptor> in, std::shared_ptr<connection
7272
}
7373

7474
// Called from the main function (see main.cpp)
75-
auto co_main(config const& cfg) -> net::awaitable<void>
75+
auto co_main(config cfg) -> net::awaitable<void>
7676
{
7777
auto ex = co_await net::this_coro::executor;
7878
auto conn = std::make_shared<connection>(ex);

examples/cpp20_containers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ auto transaction(std::shared_ptr<connection> conn) -> net::awaitable<void>
8989
}
9090

9191
// Called from the main function (see main.cpp)
92-
net::awaitable<void> co_main(config const& cfg)
92+
net::awaitable<void> co_main(config cfg)
9393
{
9494
auto conn = std::make_shared<connection>(co_await net::this_coro::executor);
9595
conn->async_run(cfg, {}, net::consign(net::detached, conn));

examples/cpp20_echo_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ auto listener(std::shared_ptr<connection> conn) -> net::awaitable<void>
5555
}
5656

5757
// Called from the main function (see main.cpp)
58-
auto co_main(config const& cfg) -> net::awaitable<void>
58+
auto co_main(config cfg) -> net::awaitable<void>
5959
{
6060
auto ex = co_await net::this_coro::executor;
6161
auto conn = std::make_shared<connection>(ex);

examples/cpp20_intro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using boost::redis::logger;
2121
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
2222

2323
// Called from the main function (see main.cpp)
24-
auto co_main(config const& cfg) -> net::awaitable<void>
24+
auto co_main(config cfg) -> net::awaitable<void>
2525
{
2626
auto conn = std::make_shared<connection>(co_await net::this_coro::executor);
2727
conn->async_run(cfg, {}, net::consign(net::detached, conn));

examples/cpp20_intro_tls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ auto verify_certificate(bool, net::ssl::verify_context&) -> bool
2626
return true;
2727
}
2828

29-
auto co_main(config const&) -> net::awaitable<void>
29+
auto co_main(config cfg) -> net::awaitable<void>
3030
{
3131
config cfg;
3232
cfg.username = "aedis";

examples/cpp20_json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void boost_redis_to_bulk(std::string& to, user const& u)
4545
void boost_redis_from_bulk(user& u, std::string_view sv, boost::system::error_code& ec)
4646
{ boost::redis::json::from_bulk(u, sv, ec); }
4747

48-
net::awaitable<void> co_main(config const& cfg)
48+
auto co_main(config cfg) -> net::awaitable<void>
4949
{
5050
auto ex = co_await net::this_coro::executor;
5151
auto conn = std::make_shared<connection>(ex);

examples/cpp20_resolve_with_sentinel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ auto resolve_master_address(std::vector<address> const& addresses) -> net::await
5555
co_return address{};
5656
}
5757

58-
auto co_main(config const& cfg) -> net::awaitable<void>
58+
auto co_main(config cfg) -> net::awaitable<void>
5959
{
6060
// A list of sentinel addresses from which only one is responsive.
6161
// This simulates sentinels that are down.

examples/cpp20_streams.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
#if defined(BOOST_ASIO_HAS_CO_AWAIT)
1717

18+
#include <memory>
19+
#include <string>
20+
#include <thread>
21+
#include <vector>
22+
1823
namespace net = boost::asio;
1924
using boost::redis::config;
2025
using boost::redis::generic_response;
@@ -72,7 +77,6 @@ auto stream_reader(std::shared_ptr<connection> conn) -> net::awaitable<void>
7277
req.clear();
7378
resp.value().clear();
7479
}
75-
7680
}
7781

7882
// Run this in another terminal:
@@ -82,6 +86,9 @@ auto co_main(config cfg) -> net::awaitable<void>
8286
auto ex = co_await net::this_coro::executor;
8387
auto conn = std::make_shared<connection>(ex);
8488
net::co_spawn(ex, stream_reader(conn), net::detached);
89+
90+
// Disable health checks.
91+
cfg.health_check_interval = std::chrono::seconds{0};
8592
conn->async_run(cfg, {}, net::consign(net::detached, conn));
8693

8794
signal_set sig_set(ex, SIGINT, SIGTERM);

examples/cpp20_subscriber.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ receiver(std::shared_ptr<connection> conn) -> net::awaitable<void>
7272
}
7373
}
7474

75-
auto co_main(config const& cfg) -> net::awaitable<void>
75+
auto co_main(config cfg) -> net::awaitable<void>
7676
{
7777
auto ex = co_await net::this_coro::executor;
7878
auto conn = std::make_shared<connection>(ex);

0 commit comments

Comments
 (0)