2
0
mirror of https://github.com/boostorg/redis.git synced 2026-01-19 04:42:09 +00:00

Build fixes.

This commit is contained in:
Marcelo Zimbres
2022-10-08 22:24:20 +02:00
parent c01a57b6cb
commit 4fb2b20954
10 changed files with 86 additions and 78 deletions

128
README.md
View File

@@ -26,7 +26,70 @@ with only three library entities
Let us see how it works in more detail.
### Connection
### Installation
Download the latest Aedis release from github
```cpp
$ wget https://github.com/mzimbres/aedis/releases/download/v1.1.0/aedis-1.1.0.tar.gz
```
and unpack in your preferred location. Aedis is a header only
library, so you can starting using it. For that include the
following header
```cpp
#include <aedis/src.hpp>
```
in no more than one source file in your applications (see intro.cpp
for example). To build the examples and run the tests cmake is also
supported
```cpp
$ BOOST_ROOT=/opt/boost_1_79_0/ cmake
$ make
$ make test
```
These are the requirements for using Aedis
- Boost 1.79 or greater.
- C++17. Some examples require C++20 with coroutine support.
- Redis 6 or higher. Optionally also redis-cli and Redis Sentinel.
The following compilers are supported
- Tested with gcc: 10, 11, 12.
- Tested with clang: 11, 13, 14.
### Examples
Users are encouraged to skim over the examples below before proceeding
to the next sections
* intro.cpp: The Aedis hello-world program. It sends one command to Redis and quits the connection.
* intro_tls.cpp: Same as intro.cpp but over TLS.
* intro_sync.cpp: Synchronous version of intro.cpp.
* containers.cpp: Shows how to send and receive stl containers and how to use transactions.
* serialization.cpp: Shows how to serialize types using Boost.Json.
* subscriber.cpp: Shows how to implement pubsub that reconnects and resubscribes when the connection is lost.
* subscriber_sentinel.cpp: Same as subscriber.cpp but with failover with sentinels.
* echo_server.cpp: A simple TCP echo server.
* chat_room.cpp: A simple chat room.
<a name="api-reference"></a>
### API Reference
* [High-Level](#high-level-api): Recommend to all users
* [Low-Level](#low-level-api): For users with needs yet to be imagined by the author.
In the next sections we will see how to create requests and receive
responses with more detail
## Connection
The code below will establish a connection with a Redis
server where users can send commands (see intro.cpp)
@@ -166,69 +229,6 @@ The problem with this approach in Aedis is twofold
causing all other (independent) requests in the same pipeline to
fail too.
### Installation
Download the latest Aedis release from github
```cpp
$ wget https://github.com/mzimbres/aedis/releases/download/v1.1.0/aedis-1.1.0.tar.gz
```
and unpack in your preferred location. Aedis is a header only
library, so you can starting using it. For that include the
following header
```cpp
#include <aedis/src.hpp>
```
in no more than one source file in your applications (see intro.cpp
for example). To build the examples and run the tests cmake is also
supported
```cpp
$ BOOST_ROOT=/opt/boost_1_79_0/ cmake
$ make
$ make test
```
These are the requirements for using Aedis
- Boost 1.79 or greater.
- C++17. Some examples require C++20 with coroutine support.
- Redis 6 or higher. Optionally also redis-cli and Redis Sentinel.
The following compilers are supported
- Tested with gcc: 10, 11, 12.
- Tested with clang: 11, 13, 14.
### Examples
Users are encouraged to skim over the examples below before proceeding
to the next sections
* intro.cpp: The Aedis hello-world program. It sends one command to Redis and quits the connection.
* intro_tls.cpp: Same as intro.cpp but over TLS.
* intro_sync.cpp: Synchronous version of intro.cpp.
* containers.cpp: Shows how to send and receive stl containers and how to use transactions.
* serialization.cpp: Shows how to serialize types using Boost.Json.
* subscriber.cpp: Shows how to implement pubsub that reconnects and resubscribes when the connection is lost.
* subscriber_sentinel.cpp: Same as subscriber.cpp but with failover with sentinels.
* echo_server.cpp: A simple TCP echo server.
* chat_room.cpp: A simple chat room.
<a name="api-reference"></a>
### API Reference
* [High-Level](#high-level-api): Recommend to all users
* [Low-Level](#low-level-api): For users with needs yet to be imagined by the author.
In the next sections we will see how to create requests and receive
responses with more detail
## Requests
Redis requests are composed of one of more Redis commands (in

View File

@@ -6,6 +6,7 @@
#include <iostream>
#include <boost/asio.hpp>
#if defined(BOOST_ASIO_HAS_CO_AWAIT)
namespace net = boost::asio;
@@ -62,3 +63,6 @@ int main(int argc, char* argv[])
std::cerr << e.what() << std::endl;
}
}
#else // defined(BOOST_ASIO_HAS_CO_AWAIT)
auto main() -> int {std::cout << "Requires coroutine support." << std::endl; return 1;}
#endif // defined(BOOST_ASIO_HAS_CO_AWAIT)

View File

@@ -10,6 +10,7 @@
#include <cstdio>
#include <boost/asio.hpp>
#if defined(BOOST_ASIO_HAS_CO_AWAIT)
namespace net = boost::asio;
namespace this_coro = net::this_coro;
@@ -56,3 +57,6 @@ int main()
std::printf("Exception: %s\n", e.what());
}
}
#else // defined(BOOST_ASIO_HAS_CO_AWAIT)
auto main() -> int {std::cout << "Requires coroutine support." << std::endl; return 1;}
#endif // defined(BOOST_ASIO_HAS_CO_AWAIT)

View File

@@ -40,7 +40,7 @@ using stimer = net::use_awaitable_t<>::as_default_on_t<net::steady_timer>;
net::awaitable<void> push_receiver(std::shared_ptr<connection> conn)
{
for (std::vector<node<std::string>> resp;;) {
co_await conn->async_receive_push(adapt(resp));
co_await conn->async_receive(adapt(resp));
print_push(resp);
resp.clear();
}

View File

@@ -48,7 +48,7 @@ using connection = aedis::connection<tcp_socket>;
net::awaitable<void> push_receiver(std::shared_ptr<connection> conn)
{
for (std::vector<node<std::string>> resp;;) {
co_await conn->async_receive_push(adapt(resp));
co_await conn->async_receive(adapt(resp));
print_push(resp);
resp.clear();
}

View File

@@ -36,7 +36,7 @@ using connection = aedis::connection<tcp_socket>;
net::awaitable<void> receive_pushes(std::shared_ptr<connection> conn)
{
for (std::vector<node<std::string>> resp;;) {
co_await conn->async_receive_push(adapt(resp));
co_await conn->async_receive(adapt(resp));
print_push(resp);
resp.clear();
}

View File

@@ -201,11 +201,11 @@ public:
template <
class Adapter = detail::response_traits<void>::adapter_type,
class CompletionToken = boost::asio::default_completion_token_t<executor_type>>
auto async_receive_push(
auto async_receive(
Adapter adapter = adapt(),
CompletionToken token = CompletionToken{})
{
return base_type::async_receive_push(adapter, std::move(token));
return base_type::async_receive(adapter, std::move(token));
}
/** @brief Cancel operations.
@@ -221,7 +221,7 @@ public:
* `error::idle_timeout`. Calling `cancel(operation::run)`
* directly should be seen as the last option.
* @li operation::receive_push: Cancels any ongoing callto
* `async_receive_push`.
* `async_receive`.
*
* @param op: The operation to be cancelled.
* @returns The number of operations that have been canceled.

View File

@@ -125,7 +125,7 @@ public:
template <
class Adapter = detail::response_traits<void>::adapter_type,
class CompletionToken = boost::asio::default_completion_token_t<executor_type>>
auto async_receive_push(
auto async_receive(
Adapter adapter = adapt(),
CompletionToken token = CompletionToken{})
{

View File

@@ -123,16 +123,16 @@ public:
/** @brief Receives server side pushes asynchronously.
*
* See aedis::connection::async_receive_push for detailed information.
* See aedis::connection::async_receive for detailed information.
*/
template <
class Adapter = aedis::detail::response_traits<void>::adapter_type,
class CompletionToken = boost::asio::default_completion_token_t<executor_type>>
auto async_receive_push(
auto async_receive(
Adapter adapter = adapt(),
CompletionToken token = CompletionToken{})
{
return base_type::async_receive_push(adapter, std::move(token));
return base_type::async_receive(adapter, std::move(token));
}
/** @brief Cancel operations.

View File

@@ -88,12 +88,12 @@ void test_missing_push_reader3(bool coalesce)
net::awaitable<void> push_consumer1(std::shared_ptr<connection> conn, bool& push_received)
{
{
auto [ec, ev] = co_await conn->async_receive_push(adapt(), as_tuple(net::use_awaitable));
auto [ec, ev] = co_await conn->async_receive(adapt(), as_tuple(net::use_awaitable));
BOOST_TEST(!ec);
}
{
auto [ec, ev] = co_await conn->async_receive_push(adapt(), as_tuple(net::use_awaitable));
auto [ec, ev] = co_await conn->async_receive(adapt(), as_tuple(net::use_awaitable));
BOOST_CHECK_EQUAL(ec, boost::asio::experimental::channel_errc::channel_cancelled);
}
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(test_push_adapter)
req.push("SUBSCRIBE", "channel");
req.push("PING");
conn->async_receive_push(adapter_error{}, [](auto ec, auto) {
conn->async_receive(adapter_error{}, [](auto ec, auto) {
BOOST_CHECK_EQUAL(ec, aedis::error::incompatible_size);
});
@@ -219,7 +219,7 @@ void test_push_is_received2(bool coalesce)
net::awaitable<void> push_consumer3(std::shared_ptr<connection> conn)
{
for (;;)
co_await conn->async_receive_push(adapt(), net::use_awaitable);
co_await conn->async_receive(adapt(), net::use_awaitable);
}
// Test many subscribe requests.