Skip to content

Commit c88fcfb

Browse files
committed
Adds more doc to node class.
1 parent a56bf98 commit c88fcfb

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ that implements the latest version of the Redis communication
66
protocol
77
[RESP3](https://github.com/redis/redis-specifications/blob/master/protocol/RESP3.md).
88
It makes communication with a Redis server easy by hiding low-level
9-
Asio-related code away from the user, which, in the majority of the
10-
cases will be concerned with only three library entities
9+
code away from the user, which, in the majority of the cases will be
10+
concerned with only three library entities
1111

12-
* `aedis::connection`: A connection to the Redis server that
13-
implements automatic
14-
[pipelining](https://redis.io/docs/manual/pipelining/) and which can
15-
handle requests and server pushes concurrently.
12+
* `aedis::connection`: A connection to the Redis server with
13+
high-level functions to execute Redis commands, receive server
14+
pushes and support for automatic command
15+
[pipelines](https://redis.io/docs/manual/pipelining/).
1616
* `aedis::resp3::request`: A container of Redis commands that supports
1717
STL containers and user defined data types.
1818
* `aedis::adapt()`: A function that adapts data structures to receive responses.
1919

20-
In the next sections we will cover all those points in detail and with
20+
In the next sections we will cover all those points in detail with
2121
examples. The requirements for using Aedis are
2222

2323
* Boost 1.80 or greater.
@@ -53,7 +53,7 @@ auto co_main() -> net::awaitable<void>
5353
// From examples/common.hpp to avoid vebosity
5454
co_await connect(conn, "127.0.0.1", "6379");
5555

56-
// A request can contains multiple commands.
56+
// A request can contain multiple commands.
5757
resp3::request req;
5858
req.push("HELLO", 3);
5959
req.push("HGETALL", "hset-key");
@@ -71,8 +71,8 @@ auto co_main() -> net::awaitable<void>
7171
```
7272

7373
The example above uses the Asio awaitable `operator ||` to compose
74-
`connection::async_exec` and `connection::async_run` in a single
75-
operation we can `co_await` on. It also provides cancelation one of
74+
`connection::async_exec` and `connection::async_run` in an
75+
operation we can `co_await` on. It also provides cancelation of one of
7676
the operations when the other completes. The role played by these
7777
functions are
7878

include/aedis/resp3/node.hpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,33 @@ namespace aedis::resp3 {
1414
/** \brief A node in the response tree.
1515
* \ingroup high-level-api
1616
*
17-
* Redis responses are the pre-order view of the response tree (see
18-
* https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR).
17+
* RESP3 can contain recursive data structures: A map of sets of
18+
* vector of etc. As it is parsed each element is passed to user
19+
* callbacks (push parser), the `aedis::adapt` function. The signature of this
20+
* callback is `f(resp3::node<std::string_view)`. This class is called a node
21+
* because it can be seen as the element of the response tree. It
22+
* is a template so that users can use it with owing strings e.g.
23+
* `std::string` or `boost::static_string` etc. if they decide to use a node as
24+
* response type, for example, to read a non-aggregate data-type use
1925
*
20-
* \remark Any Redis response can be received in an array of nodes,
21-
* for example \c std::vector<node<std::string>>.
26+
* ```cpp
27+
* resp3::node<std::string> resp;
28+
* co_await conn->async_exec(req, adapt(resp));
29+
* ```
30+
*
31+
* for an aggregate use instead
32+
*
33+
* ```cpp
34+
* std::vector<resp3::node<std::string>> resp; co_await
35+
* conn->async_exec(req, adapt(resp));
36+
* ```
37+
*
38+
* The vector will contain the
39+
* [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
40+
* view of the response tree. Any Redis response can be received in
41+
* an array of nodes as shown above.
42+
*
43+
* \tparam String A `std::string`-like type.
2244
*/
2345
template <class String>
2446
struct node {

0 commit comments

Comments
 (0)