Skip to content

Commit cd46e39

Browse files
authored
Boost 1.90.0 beta1: merge develop to master
2 parents 76129bb + 6791e75 commit cd46e39

File tree

96 files changed

+7779
-2741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+7779
-2741
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,41 +137,47 @@ jobs:
137137
cxxstd: '17'
138138
build-type: 'Debug'
139139
ldflags: ''
140+
server: "redis:7.4.5-alpine"
140141

141142
- toolset: gcc-11
142143
install: g++-11
143144
container: ubuntu:22.04
144145
cxxstd: '20'
145146
build-type: 'Release'
146147
ldflags: ''
148+
server: "redis:7.4.5-alpine"
147149

148150
- toolset: clang-11
149151
install: clang-11
150152
container: ubuntu:22.04
151153
cxxstd: '17'
152154
build-type: 'Debug'
153155
ldflags: ''
156+
server: "redis:7.4.5-alpine"
154157

155158
- toolset: clang-11
156159
install: clang-11
157160
container: ubuntu:22.04
158161
cxxstd: '20'
159162
build-type: 'Debug'
160163
ldflags: ''
164+
server: "redis:7.4.5-alpine"
161165

162166
- toolset: clang-13
163167
install: clang-13
164168
container: ubuntu:22.04
165169
cxxstd: '17'
166170
build-type: 'Release'
167171
ldflags: ''
172+
server: "redis:8.2.1-alpine"
168173

169174
- toolset: clang-13
170175
install: clang-13
171176
container: ubuntu:22.04
172177
cxxstd: '20'
173178
build-type: 'Release'
174179
ldflags: ''
180+
server: "redis:8.2.1-alpine"
175181

176182
- toolset: clang-14
177183
install: 'clang-14 libc++-14-dev libc++abi-14-dev'
@@ -180,6 +186,7 @@ jobs:
180186
build-type: 'Debug'
181187
cxxflags: '-stdlib=libc++'
182188
ldflags: '-lc++'
189+
server: "redis:8.2.1-alpine"
183190

184191
- toolset: clang-14
185192
install: 'clang-14 libc++-14-dev libc++abi-14-dev'
@@ -188,6 +195,7 @@ jobs:
188195
build-type: 'Release'
189196
cxxflags: '-stdlib=libc++'
190197
ldflags: '-lc++'
198+
server: "redis:8.2.1-alpine"
191199

192200
- toolset: clang-19
193201
install: 'clang-19'
@@ -196,13 +204,15 @@ jobs:
196204
build-type: 'Debug'
197205
cxxflags: '-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all'
198206
ldflags: '-fsanitize=address -fsanitize=undefined'
207+
server: "redis:8.2.1-alpine"
199208

200209
- toolset: gcc-14
201210
install: 'g++-14'
202211
container: ubuntu:24.04
203212
cxxstd: '23'
204213
build-type: 'Debug'
205214
cxxflags: '-DBOOST_ASIO_DISABLE_LOCAL_SOCKETS=1' # If a system had no UNIX socket support, we build correctly
215+
server: "valkey/valkey:8.1.3-alpine"
206216

207217
- toolset: gcc-14
208218
install: 'g++-14'
@@ -211,6 +221,7 @@ jobs:
211221
build-type: 'Debug'
212222
cxxflags: '-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all'
213223
ldflags: '-fsanitize=address -fsanitize=undefined'
224+
server: "valkey/valkey:8.1.3-alpine"
214225

215226
runs-on: ubuntu-latest
216227
env:
@@ -224,7 +235,7 @@ jobs:
224235

225236
- name: Set up the required containers
226237
run: |
227-
IMAGE=${{ matrix.container }} docker compose -f tools/docker-compose.yml up -d --wait || (docker compose logs; exit 1)
238+
BUILDER_IMAGE=${{ matrix.container }} SERVER_IMAGE=${{ matrix.server }} docker compose -f tools/docker-compose.yml up -d --wait || (docker compose logs; exit 1)
228239
229240
- name: Install dependencies
230241
run: |

CMakePresets.json

Lines changed: 0 additions & 178 deletions
This file was deleted.

doc/build_antora.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ cd "$SCRIPT_DIR"
1616
export BOOST_SRC_DIR=$(realpath $SCRIPT_DIR/../../..)
1717

1818
npm ci
19-
npx antora --log-format=pretty redis-playbook.yml
19+
npx antora --log-format=pretty --stacktrace --log-level info redis-playbook.yml

doc/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* xref:index.adoc[Introduction]
22
* xref:requests_responses.adoc[]
3+
* xref:cancellation.adoc[]
34
* xref:serialization.adoc[]
45
* xref:logging.adoc[]
56
* xref:benchmarks.adoc[]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
//
2+
// Copyright (c) 2025 Marcelo Zimbres Silva ([email protected]),
3+
// Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
4+
//
5+
// Distributed under the Boost Software License, Version 1.0. (See accompanying
6+
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7+
//
8+
9+
= Cancellation and timeouts
10+
11+
By default, running a request with xref:reference:boost/redis/basic_connection/async_exec-02.adoc[`async_exec`]
12+
will wait until a connection to the Redis server is established by `async_run`.
13+
This may take a very long time if the server is down.
14+
15+
For this reason, it is usually a good idea to set a timeout to `async_exec`
16+
operations using the
17+
https://www.boost.org/doc/libs/latest/doc/html/boost_asio/reference/cancel_after.html[`asio::cancel_after`]
18+
completion token:
19+
20+
21+
[source,cpp]
22+
----
23+
using namespace std::chrono_literals;
24+
25+
// Compose a request with a SET command
26+
request req;
27+
req.push("SET", "my_key", 42);
28+
29+
// If the request hasn't completed after 10 seconds, it will be cancelled
30+
// and an exception will be thrown.
31+
co_await conn.async_exec(req, ignore, asio::cancel_after(10s));
32+
----
33+
34+
See our {site-url}/example/cpp20_timeouts.cpp[example on timeouts]
35+
for a full code listing.
36+
37+
You can also use `cancel_after` with other completion styles, like
38+
callbacks and futures.
39+
40+
`cancel_after` works because `async_exec` supports the per-operation
41+
cancellation mechanism. This is used by Boost.Asio to implement features
42+
like `cancel_after` and parallel groups. All asynchronous operations
43+
in the library support this mechanism. Please consult the documentation
44+
for individual operations for more info.
45+
46+
47+
== Retrying idempotent requests
48+
49+
We mentioned that `async_exec` waits until the server is up
50+
before sending the request. But what happens if there is a communication
51+
error after sending the request, but before receiving a response?
52+
53+
In this situation there is no way to know if the request was processed by the server or not.
54+
By default, the library will consider the request as failed,
55+
and `async_exec` will complete with an `asio::error::operation_aborted`
56+
error code.
57+
58+
Some requests can be executed several times and result in the same outcome
59+
as executing them only once. We say that these requests are _idempotent_.
60+
The `SET` command is idempotent, while `INCR` is not.
61+
62+
If you know that a `request` object contains only idempotent commands,
63+
you can instruct Boost.Redis to retry the request on failure, even
64+
if the library is unsure about the server having processed the request or not.
65+
You can do so by setting `cancel_if_unresponded`
66+
in xref:reference:boost/redis/request/config.adoc[`request::config`]
67+
to false:
68+
69+
[source,cpp]
70+
----
71+
// Compose a request
72+
request req;
73+
req.push("SET", "my_key", 42); // idempotent
74+
req.get_config().cancel_if_unresponded = false; // Retry the request even if it was written but not responded
75+
76+
// Makes sure that the key is set, even in the presence of network errors.
77+
// This may suspend for an unspecified period of time if the server is down.
78+
co_await conn.async_exec(req, ignore);
79+
----

doc/modules/ROOT/pages/index.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
[#intro]
99
= Introduction
1010

11-
Boost.Redis is a high-level https://redis.io/[Redis] client library built on top of
11+
Boost.Redis is a high-level https://redis.io/[Redis] and https://valkey.io/[Valkey]
12+
client library built on top of
1213
https://www.boost.org/doc/libs/latest/doc/html/boost_asio.html[Boost.Asio]
1314
that implements the Redis protocol
1415
https://github.com/redis/redis-specifications/blob/master/protocol/RESP3.md[RESP3].
@@ -19,7 +20,8 @@ The requirements for using Boost.Redis are:
1920

2021
* Boost 1.84 or higher. Boost.Redis is included in Boost installations since Boost 1.84.
2122
* pass:[C++17] or higher. Supported compilers include gcc 11 and later, clang 11 and later, and Visual Studio 16 (2019) and later.
22-
* Redis 6 or higher (must support RESP3).
23+
* Redis 6 or higher, or Valkey (any version). The database server must support RESP3.
24+
We intend to maintain compatibility with both Redis and Valkey in the long-run.
2325
* OpenSSL.
2426

2527
The documentation assumes basic-level knowledge about https://redis.io/docs/[Redis] and https://www.boost.org/doc/libs/latest/doc/html/boost_asio.html[Boost.Asio].
@@ -137,6 +139,7 @@ receiver(std::shared_ptr<connection> conn) -> net::awaitable<void>
137139

138140
Here is a list of topics that you might be interested in:
139141

142+
* xref:cancellation.adoc[Setting timeouts to requests and managing cancellation].
140143
* xref:requests_responses.adoc[More on requests and responses].
141144
* xref:serialization.adoc[Serializing and parsing into custom types].
142145
* xref:logging.adoc[Configuring logging].

0 commit comments

Comments
 (0)