wexample-queue 2.0.4__py3-none-any.whl → 2.0.6__py3-none-any.whl

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.
File without changes
File without changes
File without changes
wexample_queue/py.typed CHANGED
File without changes
File without changes
File without changes
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.1
2
+ Name: wexample-queue
3
+ Version: 2.0.6
4
+ Summary: Manage Queuing
5
+ Author-Email: weeger <contact@wexample.com>
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.10
11
+ Requires-Dist: pika>=1.3.0
12
+ Requires-Dist: wexample-app>=19.4.2
13
+ Requires-Dist: wexample-helpers>=20.6.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest; extra == "dev"
16
+ Requires-Dist: pytest-cov; extra == "dev"
17
+ Description-Content-Type: text/markdown
18
+
19
+ # queue
20
+
21
+ Version: 2.0.6
22
+
23
+ Manage Queuing
24
+
25
+ ## Table of Contents
26
+
27
+ - [Install](#install)
28
+ - [Tests](#tests)
29
+ - [Roadmap](#roadmap)
30
+ - [Status Compatibility](#status-compatibility)
31
+ - [Useful Links](#useful-links)
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install wexample-queue
37
+ ```
38
+
39
+ Requires Python >=3.10.
40
+
41
+ ## Tests
42
+
43
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
44
+
45
+ ### Installation
46
+
47
+ First, install the required testing dependencies:
48
+ ```bash
49
+ .venv/bin/python -m pip install pytest pytest-cov
50
+ ```
51
+
52
+ ### Basic Usage
53
+
54
+ Run all tests with coverage:
55
+ ```bash
56
+ .venv/bin/python -m pytest --cov --cov-report=html
57
+ ```
58
+
59
+ ### Common Commands
60
+ ```bash
61
+ # Run tests with coverage for a specific module
62
+ .venv/bin/python -m pytest --cov=your_module
63
+
64
+ # Show which lines are not covered
65
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
66
+
67
+ # Generate an HTML coverage report
68
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
69
+
70
+ # Combine terminal and HTML reports
71
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
72
+
73
+ # Run specific test file with coverage
74
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
75
+ ```
76
+
77
+ ### Viewing HTML Reports
78
+
79
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
80
+
81
+ ### Coverage Threshold
82
+
83
+ To enforce a minimum coverage percentage:
84
+ ```bash
85
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
86
+ ```
87
+
88
+ This will cause the test suite to fail if coverage drops below 80%.
89
+
90
+ ## Known Limitations & Roadmap
91
+
92
+ Current limitations and planned features are tracked in the GitHub issues.
93
+
94
+ See the [project roadmap](https://github.com/wexample/python-queue/issues) for upcoming features and improvements.
95
+
96
+ ## Status & Compatibility
97
+
98
+ **Maturity**: Production-ready
99
+
100
+ **Python Support**: >=3.10
101
+
102
+ **OS Support**: Linux, macOS, Windows
103
+
104
+ **Status**: Actively maintained
105
+
106
+ ## Useful Links
107
+
108
+ - **Homepage**: https://github.com/wexample/python-queue
109
+ - **Issue Tracker**: https://github.com/wexample/python-queue/issues
110
+ - **Discussions**: https://github.com/wexample/python-queue/discussions
111
+ - **PyPI**: [pypi.org/project/wexample-queue](https://pypi.org/project/wexample-queue/)
@@ -1,10 +1,10 @@
1
- wexample_queue-2.0.4.dist-info/METADATA,sha256=BriKajcQnr8kIg5hORbretreCQXTDImS93BH9yO1-h4,10206
2
- wexample_queue-2.0.4.dist-info/WHEEL,sha256=IuIk3wbaEnFH1cx75iM2R1CmliRI3dFLXTbRakgvgFQ,90
3
- wexample_queue-2.0.4.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ wexample_queue-2.0.6.dist-info/METADATA,sha256=mnpCreNk4Vofadcj3gtbCTkCxu2EUE2PXXQw4wOmn1M,2818
2
+ wexample_queue-2.0.6.dist-info/WHEEL,sha256=IuIk3wbaEnFH1cx75iM2R1CmliRI3dFLXTbRakgvgFQ,90
3
+ wexample_queue-2.0.6.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
4
  wexample_queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  wexample_queue/connector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  wexample_queue/connector/rabbitmq_external_connector.py,sha256=-Pd2cI6o5Oj4ojCYVzGkFzxexI3TnzQWq_qsMSuWtJk,6130
7
7
  wexample_queue/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  wexample_queue/service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  wexample_queue/service/abstract_queue_service.py,sha256=hgcVpbUXj7F9CpWnrG0ertmkRbQZMw1kGGgTF_hOyjo,7167
10
- wexample_queue-2.0.4.dist-info/RECORD,,
10
+ wexample_queue-2.0.6.dist-info/RECORD,,
@@ -1,260 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: wexample-queue
3
- Version: 2.0.4
4
- Summary: Manage Queuing
5
- Author-Email: weeger <contact@wexample.com>
6
- License: MIT
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.10
11
- Requires-Dist: pika>=1.3.0
12
- Requires-Dist: wexample-app>=19.4.0
13
- Requires-Dist: wexample-helpers>=20.5.0
14
- Provides-Extra: dev
15
- Requires-Dist: pytest; extra == "dev"
16
- Requires-Dist: pytest-cov; extra == "dev"
17
- Description-Content-Type: text/markdown
18
-
19
- # queue
20
-
21
- Version: 2.0.4
22
-
23
- `wexample-queue` is what a worker needs to live on a RabbitMQ queue and nothing more: a connector holding the broker connection, and a service base whose whole subject is one queue. A subclass writes the name of the queue and what to do with a message; connecting, declaring, decoding, acknowledging and giving up are the same for every worker and are already written.
24
-
25
- It exists because the other end of the queue is not always Python. The body of a message is plain JSON, published on the default exchange with the queue name as routing key — which is where a Symfony Messenger transport declaring that same queue binds its own exchange, so both ends meet in the same place without either knowing the other.
26
-
27
- ## A worker
28
-
29
- ```python
30
- from wexample_queue.service.abstract_queue_service import AbstractQueueService
31
-
32
- @base_class
33
- class ProcessRunService(AbstractQueueService):
34
- queue_name: str = public_field(
35
- default="process_run",
36
- description="Name of the queue this service consumes",
37
- )
38
-
39
- def process_message(self, message: dict[str, Any]) -> None:
40
- self.log(f"Run {message['id']} asked for in {message['workdir']}")
41
- ```
42
-
43
- Calling `start()` opens the connection, declares the queue and blocks consuming
44
- until `stop()`. Returning from `process_message()` acknowledges the message;
45
- raising rejects it without putting it back, because requeueing a message that
46
- just failed is asking for the same failure at once and for ever. Where it goes
47
- then is the broker's business — a dead letter exchange if the queue has one,
48
- nowhere if it has not.
49
-
50
- ## Publishing
51
-
52
- ```python
53
- self.connector.publish("process_run_event", {"kind": "process_run", "id": run_id})
54
- ```
55
-
56
- ## The broker
57
-
58
- Where the broker is comes from the environment, under four keys the connector
59
- declares as expected:
60
-
61
- ```
62
- RABBITMQ_HOST
63
- RABBITMQ_PORT
64
- RABBITMQ_USER
65
- RABBITMQ_PASSWORD
66
- ```
67
-
68
- Reading them from there rather than from a caller is what keeps a worker and
69
- whoever publishes to it from holding two addresses that could disagree.
70
-
71
- ## Table of Contents
72
-
73
- - [A worker](#a-worker)
74
- - [Publishing](#publishing)
75
- - [The broker](#the-broker)
76
- - [Installation](#installation)
77
- - [Tests](#tests)
78
- - [Architecture](#architecture)
79
- - [Integration in the Suite](#integration-in-the-suite)
80
- - [Dependencies](#dependencies)
81
- - [Versioning & Compatibility Policy](#versioning--compatibility-policy)
82
- - [License](#license)
83
- - [About us](#about-us)
84
- - [Known Limitations & Roadmap](#known-limitations--roadmap)
85
- - [Status & Compatibility](#status--compatibility)
86
- - [Useful Links](#useful-links)
87
- - [Migration Notes](#migration-notes)
88
-
89
- ## Installation
90
-
91
- ```bash
92
- pip install wexample-queue
93
- ```
94
-
95
- Requires Python >=3.10.
96
-
97
- ```bash
98
- pip install wexample-queue
99
- ```
100
-
101
- A worker is a class with a queue name and a `process_message()`:
102
-
103
- ```python
104
- from typing import Any
105
-
106
- from wexample_helpers.classes.field import public_field
107
- from wexample_helpers.decorator.base_class import base_class
108
- from wexample_queue.service.abstract_queue_service import AbstractQueueService
109
-
110
- @base_class
111
- class HelloService(AbstractQueueService):
112
- queue_name: str = public_field(
113
- default="hello",
114
- description="Name of the queue this service consumes",
115
- )
116
-
117
- def process_message(self, message: dict[str, Any]) -> None:
118
- self.log(f"Got {message}")
119
-
120
- HelloService(kernel=kernel, queue_name="hello").start()
121
- ```
122
-
123
- `start()` blocks. The four `RABBITMQ_*` environment keys have to be readable by
124
- the kernel, which is where the connector goes to find the broker.
125
-
126
- ## Tests
127
-
128
- This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
129
-
130
- ### Installation
131
-
132
- First, install the required testing dependencies:
133
- ```bash
134
- .venv/bin/python -m pip install pytest pytest-cov
135
- ```
136
-
137
- ### Basic Usage
138
-
139
- Run all tests with coverage:
140
- ```bash
141
- .venv/bin/python -m pytest --cov --cov-report=html
142
- ```
143
-
144
- ### Common Commands
145
- ```bash
146
- # Run tests with coverage for a specific module
147
- .venv/bin/python -m pytest --cov=your_module
148
-
149
- # Show which lines are not covered
150
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
151
-
152
- # Generate an HTML coverage report
153
- .venv/bin/python -m pytest --cov=your_module --cov-report=html
154
-
155
- # Combine terminal and HTML reports
156
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
157
-
158
- # Run specific test file with coverage
159
- .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
160
- ```
161
-
162
- ### Viewing HTML Reports
163
-
164
- After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
165
-
166
- ### Coverage Threshold
167
-
168
- To enforce a minimum coverage percentage:
169
- ```bash
170
- .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
171
- ```
172
-
173
- This will cause the test suite to fail if coverage drops below 80%.
174
-
175
- ## Architecture
176
-
177
- Two classes, and the line between them is what a broker is against what a worker is.
178
-
179
- ### The connector
180
-
181
- src/wexample_queue/connector/rabbitmq_external_connector.py extends `AbstractExternalConnector` from `wexample-app` and holds a `pika.BlockingConnection` and its channel. It exposes only what this package needs — `connect`, `disconnect`, `declare_queue`, `publish`, `consume`, `stop_consuming` — and reads the broker address from four environment keys it declares in `get_expected_env_keys()`, so a worker never carries one.
182
-
183
- `publish()` goes through the default exchange with the queue name as routing key, and marks the message persistent. `declare_queue()` declares it durable, with the same arguments both ends use: neither side depends on the other having started first, and a broker restarted on its own finds its queues again.
184
-
185
- ### The service
186
-
187
- src/wexample_queue/service/abstract_queue_service.py extends `AbstractService` from `wexample-app`, which already brings the run loop, the signal handling and the shutdown. What this adds is the queue: `start()` opens the connection and declares the queue before handing over to the loop, `_run()` blocks consuming, and `_on_message()` decodes one delivery and answers the broker for it.
188
-
189
- The answer is the part worth reading. A body that is not JSON, and a message `process_message()` raised on, are both rejected with `requeue=False`. Putting such a message back would be asking for the same failure immediately and for ever; dropping it silently with an `ack` would lose it without saying so. Rejecting it hands the decision to the broker, which is the only place a dead letter exchange can be configured.
190
-
191
- Unlike the implementation this was drawn from, constructing a service does not start it. `start()` is called by whoever owns the worker, which is what makes a service testable without a broker.
192
-
193
- ## Integration in the Suite
194
-
195
- This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
196
-
197
- ### Related Packages
198
-
199
- The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
200
-
201
- ## Dependencies
202
-
203
- - pika: >=1.3.0
204
- - wexample-app: >=19.4.0
205
- - wexample-helpers: >=20.5.0
206
-
207
- ## Versioning & Compatibility Policy
208
-
209
- Wexample packages follow **Semantic Versioning** (SemVer):
210
-
211
- - **MAJOR**: Breaking changes
212
- - **MINOR**: New features, backward compatible
213
- - **PATCH**: Bug fixes, backward compatible
214
-
215
- We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
216
-
217
- ## License
218
-
219
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
220
-
221
- Free to use in both personal and commercial projects.
222
-
223
- ## About us
224
-
225
- [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
226
-
227
- This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
228
-
229
- Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
230
-
231
- Built and maintained by [Romain Weeger](https://weeger.io).
232
-
233
- ## Known Limitations & Roadmap
234
-
235
- Current limitations and planned features are tracked in the GitHub issues.
236
-
237
- See the [project roadmap](https://github.com/wexample/python-queue/issues) for upcoming features and improvements.
238
-
239
- ## Status & Compatibility
240
-
241
- **Maturity**: Production-ready
242
-
243
- **Python Support**: >=3.10
244
-
245
- **OS Support**: Linux, macOS, Windows
246
-
247
- **Status**: Actively maintained
248
-
249
- ## Useful Links
250
-
251
- - **Homepage**: https://github.com/wexample/python-queue
252
- - **Issue Tracker**: https://github.com/wexample/python-queue/issues
253
- - **Discussions**: https://github.com/wexample/python-queue/discussions
254
- - **PyPI**: [pypi.org/project/wexample-queue](https://pypi.org/project/wexample-queue/)
255
-
256
- ## Migration Notes
257
-
258
- When upgrading between major versions, refer to the migration guides in the documentation.
259
-
260
- Breaking changes are clearly documented with upgrade paths and examples.