redqueue 0.12.0__tar.gz → 0.13.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {redqueue-0.12.0 → redqueue-0.13.1}/CHANGELOG.md +68 -25
- {redqueue-0.12.0 → redqueue-0.13.1}/PKG-INFO +34 -5
- {redqueue-0.12.0 → redqueue-0.13.1}/README-zh-CN.md +85 -56
- {redqueue-0.12.0 → redqueue-0.13.1}/README.md +87 -58
- {redqueue-0.12.0 → redqueue-0.13.1}/docs/API.md +75 -46
- {redqueue-0.12.0 → redqueue-0.13.1}/pyproject.toml +13 -13
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/__init__.py +2 -1
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/__main__.py +9 -9
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/_version.py +1 -1
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/async_client.py +40 -22
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/backends/async_delay.py +372 -365
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/backends/async_list.py +463 -460
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/backends/async_stream.py +601 -596
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/backends/base.py +160 -157
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/backends/delay.py +380 -373
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/backends/list.py +460 -457
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/backends/stream.py +575 -566
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/cli.py +538 -533
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/client.py +40 -22
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/message.py +178 -127
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/monitoring.py +189 -185
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/fakes.py +20 -20
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/test_availability.py +255 -253
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/test_cli.py +356 -332
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/test_project_skeleton.py +229 -86
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/test_real_redis_availability.py +124 -123
- {redqueue-0.12.0 → redqueue-0.13.1}/.github/workflows/ci.yml +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/.gitignore +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/CODE_OF_CONDUCT.md +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/CONTRIBUTING.md +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/LICENSE +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/NOTICE +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/docs/RELEASE.md +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/README.md +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/__init__.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/async_list_queue.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/common.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/compatibility_check.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/custom_serializer.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/delayed_tasks.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/monitoring_hooks.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/stream_queue.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/examples/sync_list_queue.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/requirements.txt +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/scripts/check.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/backends/__init__.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/compat.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/config.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/connection.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/exceptions.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/src/redqueue/serialization.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/README.md +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/__init__.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/test_backend_contracts.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/test_integration_redis.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/test_performance.py +0 -0
- {redqueue-0.12.0 → redqueue-0.13.1}/tests/test_real_redis_performance.py +0 -0
|
@@ -7,39 +7,82 @@ All notable public release changes are documented here.
|
|
|
7
7
|
Development versions are tracked separately from formal release versions.
|
|
8
8
|
开发版本与正式版本分开管理。
|
|
9
9
|
|
|
10
|
-
## [0.
|
|
11
|
-
|
|
12
|
-
### Added
|
|
13
|
-
|
|
14
|
-
- Added the `redqueue` CLI and `python -m redqueue` module entry point for
|
|
15
|
-
developer debugging.
|
|
16
|
-
- Added CLI commands for Redis compatibility checks, queue statistics, message
|
|
17
|
-
publish, consume with optional ack/nack/retry, delayed scheduling, due
|
|
18
|
-
release, and dead-letter inspection.
|
|
19
|
-
- Added deterministic JSON CLI output and user-facing JSON validation errors.
|
|
20
|
-
- Added CLI unit tests with injected fake Redis and queue clients.
|
|
10
|
+
## [0.13.1] - 2026-06-27
|
|
21
11
|
|
|
22
12
|
### Fixed
|
|
23
13
|
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- 新增 `redqueue` CLI 和 `python -m redqueue` 模块入口,方便开发者调试。
|
|
30
|
-
- 新增 Redis 兼容性检查、队列统计、消息发布、消费并可选 ack/nack/retry、
|
|
31
|
-
延迟调度、到期释放和死信查看命令。
|
|
32
|
-
- CLI 输出稳定 JSON,并提供面向用户的 JSON 参数校验错误。
|
|
33
|
-
- 新增基于 fake Redis 和 fake queue client 的 CLI 单元测试。
|
|
14
|
+
- Fixed a compatibility regression where legacy messages with blank
|
|
15
|
+
`headers["trace_id"]` values could fail to construct or consume after
|
|
16
|
+
upgrading to `0.13.0`.
|
|
17
|
+
- Fixed sync and async `publish(..., delay=..., message_id=...)` so delayed
|
|
18
|
+
publishing preserves caller-provided message ids.
|
|
34
19
|
|
|
35
20
|
### 修复
|
|
36
21
|
|
|
37
|
-
-
|
|
38
|
-
|
|
22
|
+
- 修复升级到 `0.13.0` 后,历史消息中空白 `headers["trace_id"]` 可能导致
|
|
23
|
+
消息构造或消费失败的兼容性回归。
|
|
24
|
+
- 修复同步和异步 `publish(..., delay=..., message_id=...)`,现在延迟发布会
|
|
25
|
+
保留调用方传入的消息 ID。
|
|
39
26
|
|
|
40
|
-
## [0.
|
|
27
|
+
## [0.13.0] - 2026-06-27
|
|
41
28
|
|
|
42
|
-
###
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- Added first-class `trace_id` support to `Message`, sync and async
|
|
32
|
+
`publish()`, sync and async `delay()`, List, Streams, and delayed task
|
|
33
|
+
backends.
|
|
34
|
+
- Added trace propagation through message envelopes, retry, dead-letter,
|
|
35
|
+
delayed release, and requeue flows while remaining compatible with existing
|
|
36
|
+
`headers["trace_id"]` messages.
|
|
37
|
+
- Added `trace_id` to monitoring events and CLI message output for lifecycle
|
|
38
|
+
correlation.
|
|
39
|
+
- Added CLI `--trace-id` support for `publish` and `delay`.
|
|
40
|
+
- Added `new_trace_id()` helper for callers that want RedQueue-generated trace
|
|
41
|
+
identifiers.
|
|
42
|
+
|
|
43
|
+
### 新增
|
|
44
|
+
|
|
45
|
+
- `Message`、同步和异步 `publish()`、同步和异步 `delay()`、List、Streams
|
|
46
|
+
和延迟任务后端新增一等 `trace_id` 支持。
|
|
47
|
+
- trace 会穿过消息 envelope、重试、死信、延迟释放和重放流程,并兼容已有的
|
|
48
|
+
`headers["trace_id"]` 消息。
|
|
49
|
+
- 监控事件和 CLI 消息输出新增 `trace_id`,方便按链路聚合生命周期事件。
|
|
50
|
+
- CLI 的 `publish` 和 `delay` 命令新增 `--trace-id`。
|
|
51
|
+
- 新增 `new_trace_id()` helper,方便调用方生成 RedQueue trace 标识。
|
|
52
|
+
|
|
53
|
+
## [0.12.0] - 2026-06-23
|
|
54
|
+
|
|
55
|
+
### Added
|
|
56
|
+
|
|
57
|
+
- Added the `redqueue` CLI and `python -m redqueue` module entry point for
|
|
58
|
+
developer debugging.
|
|
59
|
+
- Added CLI commands for Redis compatibility checks, queue statistics, message
|
|
60
|
+
publish, consume with optional ack/nack/retry, delayed scheduling, due
|
|
61
|
+
release, and dead-letter inspection.
|
|
62
|
+
- Added deterministic JSON CLI output and user-facing JSON validation errors.
|
|
63
|
+
- Added CLI unit tests with injected fake Redis and queue clients.
|
|
64
|
+
|
|
65
|
+
### Fixed
|
|
66
|
+
|
|
67
|
+
- Normalized `BRPOPLPUSH` timeout values to integer seconds for Redis versions
|
|
68
|
+
older than 6.2, improving Redis 5.x List consume compatibility.
|
|
69
|
+
|
|
70
|
+
### 新增
|
|
71
|
+
|
|
72
|
+
- 新增 `redqueue` CLI 和 `python -m redqueue` 模块入口,方便开发者调试。
|
|
73
|
+
- 新增 Redis 兼容性检查、队列统计、消息发布、消费并可选 ack/nack/retry、
|
|
74
|
+
延迟调度、到期释放和死信查看命令。
|
|
75
|
+
- CLI 输出稳定 JSON,并提供面向用户的 JSON 参数校验错误。
|
|
76
|
+
- 新增基于 fake Redis 和 fake queue client 的 CLI 单元测试。
|
|
77
|
+
|
|
78
|
+
### 修复
|
|
79
|
+
|
|
80
|
+
- 对 Redis 6.2 以下版本使用 `BRPOPLPUSH` 时,将 timeout 规范为整数秒,
|
|
81
|
+
提升 Redis 5.x List 消费兼容性。
|
|
82
|
+
|
|
83
|
+
## [0.11.2] - 2026-06-21
|
|
84
|
+
|
|
85
|
+
### Fixed
|
|
43
86
|
|
|
44
87
|
- Fixed cleanup for directly constructed sync clients when owned Redis backend
|
|
45
88
|
initialization fails.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: redqueue
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.1
|
|
4
4
|
Summary: Redis-backed Python message queue library with List, Streams, delayed tasks, and monitoring.
|
|
5
5
|
Project-URL: Homepage, https://github.com/SpringMirror-pear/redqueue
|
|
6
6
|
Project-URL: Repository, https://github.com/SpringMirror-pear/redqueue.git
|
|
@@ -51,6 +51,7 @@ https://github.com/SpringMirror-pear/redqueue.git
|
|
|
51
51
|
- Sync client `QueueClient` and async client `AsyncQueueClient`.
|
|
52
52
|
- Redis connection pool managers for shared sync and async resources.
|
|
53
53
|
- `redqueue` CLI for local debugging and operational checks.
|
|
54
|
+
- First-class `trace_id` propagation for lifecycle tracing.
|
|
54
55
|
- Unified exception hierarchy with structured context.
|
|
55
56
|
- Monitoring events for publish, consume, ack, nack, retry, dead letter, delay,
|
|
56
57
|
and backend errors.
|
|
@@ -111,6 +112,12 @@ redqueue publish --queue emails --payload '{"to":"user@example.com"}'
|
|
|
111
112
|
redqueue consume --queue emails --timeout 1 --ack
|
|
112
113
|
```
|
|
113
114
|
|
|
115
|
+
Publish with trace correlation:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
redqueue publish --queue emails --payload '{"to":"user@example.com"}' --trace-id trace-123
|
|
119
|
+
```
|
|
120
|
+
|
|
114
121
|
Delayed task debugging:
|
|
115
122
|
|
|
116
123
|
```bash
|
|
@@ -131,7 +138,7 @@ All command output is JSON so it can be piped into scripts or log processors.
|
|
|
131
138
|
Synchronous List queue:
|
|
132
139
|
|
|
133
140
|
```python
|
|
134
|
-
from redqueue import QueueClient
|
|
141
|
+
from redqueue import QueueClient, new_trace_id
|
|
135
142
|
|
|
136
143
|
client = QueueClient.from_url(
|
|
137
144
|
"redis://127.0.0.1:6379/0",
|
|
@@ -139,11 +146,13 @@ client = QueueClient.from_url(
|
|
|
139
146
|
backend="list",
|
|
140
147
|
)
|
|
141
148
|
|
|
142
|
-
|
|
149
|
+
trace_id = new_trace_id()
|
|
150
|
+
message_id = client.publish({"to": "user@example.com"}, trace_id=trace_id)
|
|
143
151
|
message = client.consume(timeout=1)
|
|
144
152
|
|
|
145
153
|
if message is not None:
|
|
146
154
|
try:
|
|
155
|
+
print(message.trace_id)
|
|
147
156
|
print(message.payload)
|
|
148
157
|
client.ack(message)
|
|
149
158
|
except Exception:
|
|
@@ -197,10 +206,30 @@ Delayed task:
|
|
|
197
206
|
from redqueue import QueueClient
|
|
198
207
|
|
|
199
208
|
client = QueueClient.from_url("redis://127.0.0.1:6379/0", queue="emails")
|
|
200
|
-
client.delay({"to": "later@example.com"}, delay_seconds=60)
|
|
209
|
+
client.delay({"to": "later@example.com"}, delay_seconds=60, trace_id="trace-123")
|
|
201
210
|
released = client.schedule_due(limit=100)
|
|
202
211
|
```
|
|
203
212
|
|
|
213
|
+
Trace IDs:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from redqueue import InMemoryMonitoringHook, QueueClient, new_trace_id
|
|
217
|
+
|
|
218
|
+
hook = InMemoryMonitoringHook()
|
|
219
|
+
client = QueueClient.from_url(
|
|
220
|
+
"redis://127.0.0.1:6379/0",
|
|
221
|
+
queue="emails",
|
|
222
|
+
monitoring=hook,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
trace_id = new_trace_id()
|
|
226
|
+
client.publish({"to": "user@example.com"}, trace_id=trace_id)
|
|
227
|
+
message = client.consume(timeout=1)
|
|
228
|
+
|
|
229
|
+
assert message.trace_id == trace_id
|
|
230
|
+
assert hook.events[-1].trace_id == trace_id
|
|
231
|
+
```
|
|
232
|
+
|
|
204
233
|
Connection pool management:
|
|
205
234
|
|
|
206
235
|
```python
|
|
@@ -338,7 +367,7 @@ REDQUEUE_REDIS_URL=redis://127.0.0.1:6379/0 PYTHONPATH=src python -m pytest -m "
|
|
|
338
367
|
|
|
339
368
|
Latest local run on Python `3.14.5`:
|
|
340
369
|
|
|
341
|
-
- Full test suite without `REDQUEUE_REDIS_URL`: `
|
|
370
|
+
- Full test suite without `REDQUEUE_REDIS_URL`: `102 passed, 8 skipped`.
|
|
342
371
|
- Real Redis availability suite: `3 passed` with
|
|
343
372
|
`redis://127.0.0.1:6379/0`.
|
|
344
373
|
- Real Redis server: Redis for Windows `5.0.14.1`.
|
|
@@ -14,10 +14,11 @@ https://github.com/SpringMirror-pear/redqueue.git
|
|
|
14
14
|
`BRPOPLPUSH`。
|
|
15
15
|
- 基于 Redis Streams 的消费组后端,Streams 要求 Redis `>=5.0`。
|
|
16
16
|
- 基于 Redis Sorted Set 的延迟任务。
|
|
17
|
-
- 同步客户端 `QueueClient` 与异步客户端 `AsyncQueueClient`。
|
|
18
|
-
- 支持同步和异步 Redis 连接池管理器,方便多个客户端共享连接池。
|
|
19
|
-
- 提供 `redqueue` CLI,用于本地调试和运行时检查。
|
|
20
|
-
-
|
|
17
|
+
- 同步客户端 `QueueClient` 与异步客户端 `AsyncQueueClient`。
|
|
18
|
+
- 支持同步和异步 Redis 连接池管理器,方便多个客户端共享连接池。
|
|
19
|
+
- 提供 `redqueue` CLI,用于本地调试和运行时检查。
|
|
20
|
+
- 一等 `trace_id` 链路追踪能力,贯穿消息生命周期。
|
|
21
|
+
- 带结构化上下文的统一异常体系。
|
|
21
22
|
- 针对发布、消费、确认、拒绝、重试、死信、延迟和后端错误的监控事件。
|
|
22
23
|
- 通过 `INFO server` 探测 Redis 能力。
|
|
23
24
|
- Apache License 2.0。
|
|
@@ -42,61 +43,67 @@ Redis:
|
|
|
42
43
|
|
|
43
44
|
## 安装
|
|
44
45
|
|
|
45
|
-
```bash
|
|
46
|
-
pip install redqueue
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
安装后会提供 `redqueue` 命令。从源码目录调试时也可以使用
|
|
50
|
-
`python -m redqueue`。
|
|
51
|
-
|
|
52
|
-
本地开发:
|
|
46
|
+
```bash
|
|
47
|
+
pip install redqueue
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
安装后会提供 `redqueue` 命令。从源码目录调试时也可以使用
|
|
51
|
+
`python -m redqueue`。
|
|
52
|
+
|
|
53
|
+
本地开发:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python -m pip install -r requirements.txt
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## CLI
|
|
60
|
+
|
|
61
|
+
检查 Redis 兼容性:
|
|
53
62
|
|
|
54
63
|
```bash
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## 快速开始
|
|
64
|
+
redqueue check --url redis://127.0.0.1:6379/0
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
查看队列统计:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
redqueue stats --url redis://127.0.0.1:6379/0 --queue emails
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
发布和消费消息:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
redqueue publish --queue emails --payload '{"to":"user@example.com"}'
|
|
77
|
+
redqueue consume --queue emails --timeout 1 --ack
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
发布时指定 trace:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
redqueue publish --queue emails --payload '{"to":"user@example.com"}' --trace-id trace-123
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
调试延迟任务:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
redqueue delay --queue emails --payload '{"to":"later@example.com"}' --delay-seconds 60
|
|
90
|
+
redqueue schedule-due --queue emails --limit 100
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
查看死信:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
redqueue dead-letters --queue emails --limit 20
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
所有命令都输出 JSON,方便接入脚本和日志处理流程。
|
|
100
|
+
|
|
101
|
+
## 快速开始
|
|
95
102
|
|
|
96
103
|
同步 List 队列:
|
|
97
104
|
|
|
98
105
|
```python
|
|
99
|
-
from redqueue import QueueClient
|
|
106
|
+
from redqueue import QueueClient, new_trace_id
|
|
100
107
|
|
|
101
108
|
client = QueueClient.from_url(
|
|
102
109
|
"redis://127.0.0.1:6379/0",
|
|
@@ -104,11 +111,13 @@ client = QueueClient.from_url(
|
|
|
104
111
|
backend="list",
|
|
105
112
|
)
|
|
106
113
|
|
|
107
|
-
|
|
114
|
+
trace_id = new_trace_id()
|
|
115
|
+
message_id = client.publish({"to": "user@example.com"}, trace_id=trace_id)
|
|
108
116
|
message = client.consume(timeout=1)
|
|
109
117
|
|
|
110
118
|
if message is not None:
|
|
111
119
|
try:
|
|
120
|
+
print(message.trace_id)
|
|
112
121
|
print(message.payload)
|
|
113
122
|
client.ack(message)
|
|
114
123
|
except Exception:
|
|
@@ -162,10 +171,30 @@ asyncio.run(main())
|
|
|
162
171
|
from redqueue import QueueClient
|
|
163
172
|
|
|
164
173
|
client = QueueClient.from_url("redis://127.0.0.1:6379/0", queue="emails")
|
|
165
|
-
client.delay({"to": "later@example.com"}, delay_seconds=60)
|
|
174
|
+
client.delay({"to": "later@example.com"}, delay_seconds=60, trace_id="trace-123")
|
|
166
175
|
released = client.schedule_due(limit=100)
|
|
167
176
|
```
|
|
168
177
|
|
|
178
|
+
链路追踪:
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from redqueue import InMemoryMonitoringHook, QueueClient, new_trace_id
|
|
182
|
+
|
|
183
|
+
hook = InMemoryMonitoringHook()
|
|
184
|
+
client = QueueClient.from_url(
|
|
185
|
+
"redis://127.0.0.1:6379/0",
|
|
186
|
+
queue="emails",
|
|
187
|
+
monitoring=hook,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
trace_id = new_trace_id()
|
|
191
|
+
client.publish({"to": "user@example.com"}, trace_id=trace_id)
|
|
192
|
+
message = client.consume(timeout=1)
|
|
193
|
+
|
|
194
|
+
assert message.trace_id == trace_id
|
|
195
|
+
assert hook.events[-1].trace_id == trace_id
|
|
196
|
+
```
|
|
197
|
+
|
|
169
198
|
连接池管理:
|
|
170
199
|
|
|
171
200
|
```python
|
|
@@ -300,7 +329,7 @@ REDQUEUE_REDIS_URL=redis://127.0.0.1:6379/0 PYTHONPATH=src python -m pytest -m "
|
|
|
300
329
|
|
|
301
330
|
Python `3.14.5` 最新本地运行结果:
|
|
302
331
|
|
|
303
|
-
- 未设置 `REDQUEUE_REDIS_URL` 时的完整测试套件:`
|
|
332
|
+
- 未设置 `REDQUEUE_REDIS_URL` 时的完整测试套件:`102 passed, 8 skipped`。
|
|
304
333
|
- 真实 Redis 可用性套件:使用 `redis://127.0.0.1:6379/0` 时 `3 passed`。
|
|
305
334
|
- 真实 Redis 服务端:Redis for Windows `5.0.14.1`。
|
|
306
335
|
- 可用性套件覆盖:List processing 恢复、List 死信重放、Streams Redis
|
|
@@ -15,10 +15,11 @@ https://github.com/SpringMirror-pear/redqueue.git
|
|
|
15
15
|
fallback on older compatible Redis versions.
|
|
16
16
|
- Redis Streams backend with consumer groups. Streams require Redis `>=5.0`.
|
|
17
17
|
- Delayed tasks based on Redis Sorted Set.
|
|
18
|
-
- Sync client `QueueClient` and async client `AsyncQueueClient`.
|
|
19
|
-
- Redis connection pool managers for shared sync and async resources.
|
|
20
|
-
- `redqueue` CLI for local debugging and operational checks.
|
|
21
|
-
-
|
|
18
|
+
- Sync client `QueueClient` and async client `AsyncQueueClient`.
|
|
19
|
+
- Redis connection pool managers for shared sync and async resources.
|
|
20
|
+
- `redqueue` CLI for local debugging and operational checks.
|
|
21
|
+
- First-class `trace_id` propagation for lifecycle tracing.
|
|
22
|
+
- Unified exception hierarchy with structured context.
|
|
22
23
|
- Monitoring events for publish, consume, ack, nack, retry, dead letter, delay,
|
|
23
24
|
and backend errors.
|
|
24
25
|
- Redis capability detection from `INFO server`.
|
|
@@ -44,61 +45,67 @@ Redis:
|
|
|
44
45
|
|
|
45
46
|
## Installation
|
|
46
47
|
|
|
47
|
-
```bash
|
|
48
|
-
pip install redqueue
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
The package installs a `redqueue` command. You can also run it with
|
|
52
|
-
`python -m redqueue` from a source checkout.
|
|
53
|
-
|
|
54
|
-
For local development:
|
|
48
|
+
```bash
|
|
49
|
+
pip install redqueue
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The package installs a `redqueue` command. You can also run it with
|
|
53
|
+
`python -m redqueue` from a source checkout.
|
|
54
|
+
|
|
55
|
+
For local development:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
python -m pip install -r requirements.txt
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## CLI
|
|
62
|
+
|
|
63
|
+
Check Redis compatibility:
|
|
55
64
|
|
|
56
65
|
```bash
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
## Quick Start
|
|
66
|
+
redqueue check --url redis://127.0.0.1:6379/0
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Inspect queue counts:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
redqueue stats --url redis://127.0.0.1:6379/0 --queue emails
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Publish and consume messages:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
redqueue publish --queue emails --payload '{"to":"user@example.com"}'
|
|
79
|
+
redqueue consume --queue emails --timeout 1 --ack
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Publish with trace correlation:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
redqueue publish --queue emails --payload '{"to":"user@example.com"}' --trace-id trace-123
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Delayed task debugging:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
redqueue delay --queue emails --payload '{"to":"later@example.com"}' --delay-seconds 60
|
|
92
|
+
redqueue schedule-due --queue emails --limit 100
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Dead-letter inspection:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
redqueue dead-letters --queue emails --limit 20
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
All command output is JSON so it can be piped into scripts or log processors.
|
|
102
|
+
|
|
103
|
+
## Quick Start
|
|
97
104
|
|
|
98
105
|
Synchronous List queue:
|
|
99
106
|
|
|
100
107
|
```python
|
|
101
|
-
from redqueue import QueueClient
|
|
108
|
+
from redqueue import QueueClient, new_trace_id
|
|
102
109
|
|
|
103
110
|
client = QueueClient.from_url(
|
|
104
111
|
"redis://127.0.0.1:6379/0",
|
|
@@ -106,11 +113,13 @@ client = QueueClient.from_url(
|
|
|
106
113
|
backend="list",
|
|
107
114
|
)
|
|
108
115
|
|
|
109
|
-
|
|
116
|
+
trace_id = new_trace_id()
|
|
117
|
+
message_id = client.publish({"to": "user@example.com"}, trace_id=trace_id)
|
|
110
118
|
message = client.consume(timeout=1)
|
|
111
119
|
|
|
112
120
|
if message is not None:
|
|
113
121
|
try:
|
|
122
|
+
print(message.trace_id)
|
|
114
123
|
print(message.payload)
|
|
115
124
|
client.ack(message)
|
|
116
125
|
except Exception:
|
|
@@ -164,10 +173,30 @@ Delayed task:
|
|
|
164
173
|
from redqueue import QueueClient
|
|
165
174
|
|
|
166
175
|
client = QueueClient.from_url("redis://127.0.0.1:6379/0", queue="emails")
|
|
167
|
-
client.delay({"to": "later@example.com"}, delay_seconds=60)
|
|
176
|
+
client.delay({"to": "later@example.com"}, delay_seconds=60, trace_id="trace-123")
|
|
168
177
|
released = client.schedule_due(limit=100)
|
|
169
178
|
```
|
|
170
179
|
|
|
180
|
+
Trace IDs:
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from redqueue import InMemoryMonitoringHook, QueueClient, new_trace_id
|
|
184
|
+
|
|
185
|
+
hook = InMemoryMonitoringHook()
|
|
186
|
+
client = QueueClient.from_url(
|
|
187
|
+
"redis://127.0.0.1:6379/0",
|
|
188
|
+
queue="emails",
|
|
189
|
+
monitoring=hook,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
trace_id = new_trace_id()
|
|
193
|
+
client.publish({"to": "user@example.com"}, trace_id=trace_id)
|
|
194
|
+
message = client.consume(timeout=1)
|
|
195
|
+
|
|
196
|
+
assert message.trace_id == trace_id
|
|
197
|
+
assert hook.events[-1].trace_id == trace_id
|
|
198
|
+
```
|
|
199
|
+
|
|
171
200
|
Connection pool management:
|
|
172
201
|
|
|
173
202
|
```python
|
|
@@ -235,7 +264,7 @@ RedQueue uses a lightweight Git Flow model:
|
|
|
235
264
|
## Documentation
|
|
236
265
|
|
|
237
266
|
- Chinese README: [README-zh-CN.md](README-zh-CN.md)
|
|
238
|
-
- API: [docs/API.md](docs/API.md)
|
|
267
|
+
- API: [docs/API.md](docs/API.md)
|
|
239
268
|
- Examples: [examples/README.md](examples/README.md)
|
|
240
269
|
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
241
270
|
- Release process: [docs/RELEASE.md](docs/RELEASE.md)
|
|
@@ -245,7 +274,7 @@ RedQueue uses a lightweight Git Flow model:
|
|
|
245
274
|
|
|
246
275
|
## Examples
|
|
247
276
|
|
|
248
|
-
The `examples/` directory contains runnable scripts for synchronous List queues,
|
|
277
|
+
The `examples/` directory contains runnable scripts for synchronous List queues,
|
|
249
278
|
asynchronous List queues, Streams, delayed tasks, monitoring hooks, custom
|
|
250
279
|
serializers, and Redis compatibility checks.
|
|
251
280
|
|
|
@@ -305,7 +334,7 @@ REDQUEUE_REDIS_URL=redis://127.0.0.1:6379/0 PYTHONPATH=src python -m pytest -m "
|
|
|
305
334
|
|
|
306
335
|
Latest local run on Python `3.14.5`:
|
|
307
336
|
|
|
308
|
-
- Full test suite without `REDQUEUE_REDIS_URL`: `
|
|
337
|
+
- Full test suite without `REDQUEUE_REDIS_URL`: `102 passed, 8 skipped`.
|
|
309
338
|
- Real Redis availability suite: `3 passed` with
|
|
310
339
|
`redis://127.0.0.1:6379/0`.
|
|
311
340
|
- Real Redis server: Redis for Windows `5.0.14.1`.
|