taskiq-redis 1.1.0__py3-none-any.whl → 1.1.2__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.
- taskiq_redis/redis_broker.py +8 -7
- taskiq_redis/redis_cluster_broker.py +8 -6
- taskiq_redis/redis_sentinel_broker.py +6 -5
- {taskiq_redis-1.1.0.dist-info → taskiq_redis-1.1.2.dist-info}/METADATA +18 -2
- taskiq_redis-1.1.2.dist-info/RECORD +13 -0
- {taskiq_redis-1.1.0.dist-info → taskiq_redis-1.1.2.dist-info}/WHEEL +1 -1
- taskiq_redis-1.1.0.dist-info/RECORD +0 -13
- {taskiq_redis-1.1.0.dist-info → taskiq_redis-1.1.2.dist-info/licenses}/LICENSE +0 -0
taskiq_redis/redis_broker.py
CHANGED
|
@@ -251,19 +251,20 @@ class RedisStreamBroker(BaseRedisBroker):
|
|
|
251
251
|
|
|
252
252
|
:param message: message to append.
|
|
253
253
|
"""
|
|
254
|
+
queue_name = message.labels.get("queue_name") or self.queue_name
|
|
254
255
|
async with Redis(connection_pool=self.connection_pool) as redis_conn:
|
|
255
256
|
await redis_conn.xadd(
|
|
256
|
-
|
|
257
|
+
queue_name,
|
|
257
258
|
{b"data": message.message},
|
|
258
259
|
maxlen=self.maxlen,
|
|
259
260
|
approximate=self.approximate,
|
|
260
261
|
)
|
|
261
262
|
|
|
262
|
-
def _ack_generator(self, id: str) -> Callable[[], Awaitable[None]]:
|
|
263
|
+
def _ack_generator(self, id: str, queue_name: str) -> Callable[[], Awaitable[None]]:
|
|
263
264
|
async def _ack() -> None:
|
|
264
265
|
async with Redis(connection_pool=self.connection_pool) as redis_conn:
|
|
265
266
|
await redis_conn.xack(
|
|
266
|
-
|
|
267
|
+
queue_name,
|
|
267
268
|
self.consumer_group_name,
|
|
268
269
|
id,
|
|
269
270
|
)
|
|
@@ -286,12 +287,12 @@ class RedisStreamBroker(BaseRedisBroker):
|
|
|
286
287
|
noack=False,
|
|
287
288
|
count=self.count,
|
|
288
289
|
)
|
|
289
|
-
for
|
|
290
|
+
for stream, msg_list in fetched:
|
|
290
291
|
for msg_id, msg in msg_list:
|
|
291
292
|
logger.debug("Received message: %s", msg)
|
|
292
293
|
yield AckableMessage(
|
|
293
294
|
data=msg[b"data"],
|
|
294
|
-
ack=self._ack_generator(msg_id),
|
|
295
|
+
ack=self._ack_generator(id=msg_id, queue_name=stream),
|
|
295
296
|
)
|
|
296
297
|
logger.debug("Starting fetching unacknowledged messages")
|
|
297
298
|
for stream in [self.queue_name, *self.additional_streams.keys()]:
|
|
@@ -310,12 +311,12 @@ class RedisStreamBroker(BaseRedisBroker):
|
|
|
310
311
|
)
|
|
311
312
|
logger.debug(
|
|
312
313
|
"Found %d pending messages in stream %s",
|
|
313
|
-
len(pending),
|
|
314
|
+
len(pending[1]),
|
|
314
315
|
stream,
|
|
315
316
|
)
|
|
316
317
|
for msg_id, msg in pending[1]:
|
|
317
318
|
logger.debug("Received message: %s", msg)
|
|
318
319
|
yield AckableMessage(
|
|
319
320
|
data=msg[b"data"],
|
|
320
|
-
ack=self._ack_generator(msg_id),
|
|
321
|
+
ack=self._ack_generator(id=msg_id, queue_name=stream),
|
|
321
322
|
)
|
|
@@ -55,7 +55,8 @@ class ListQueueClusterBroker(BaseRedisClusterBroker):
|
|
|
55
55
|
|
|
56
56
|
:param message: message to append.
|
|
57
57
|
"""
|
|
58
|
-
|
|
58
|
+
queue_name = message.labels.get("queue_name") or self.queue_name
|
|
59
|
+
await self.redis.lpush(queue_name, message.message) # type: ignore
|
|
59
60
|
|
|
60
61
|
async def listen(self) -> AsyncGenerator[bytes, None]:
|
|
61
62
|
"""
|
|
@@ -162,17 +163,18 @@ class RedisStreamClusterBroker(BaseRedisClusterBroker):
|
|
|
162
163
|
|
|
163
164
|
:param message: message to append.
|
|
164
165
|
"""
|
|
166
|
+
queue_name = message.labels.get("queue_name") or self.queue_name
|
|
165
167
|
await self.redis.xadd(
|
|
166
|
-
|
|
168
|
+
queue_name,
|
|
167
169
|
{b"data": message.message},
|
|
168
170
|
maxlen=self.maxlen,
|
|
169
171
|
approximate=self.approximate,
|
|
170
172
|
)
|
|
171
173
|
|
|
172
|
-
def _ack_generator(self, id: str) -> Callable[[], Awaitable[None]]:
|
|
174
|
+
def _ack_generator(self, id: str, queue_name: str) -> Callable[[], Awaitable[None]]:
|
|
173
175
|
async def _ack() -> None:
|
|
174
176
|
await self.redis.xack(
|
|
175
|
-
|
|
177
|
+
queue_name,
|
|
176
178
|
self.consumer_group_name,
|
|
177
179
|
id,
|
|
178
180
|
)
|
|
@@ -192,10 +194,10 @@ class RedisStreamClusterBroker(BaseRedisClusterBroker):
|
|
|
192
194
|
block=self.block,
|
|
193
195
|
noack=False,
|
|
194
196
|
)
|
|
195
|
-
for
|
|
197
|
+
for stream, msg_list in fetched:
|
|
196
198
|
for msg_id, msg in msg_list:
|
|
197
199
|
logger.debug("Received message: %s", msg)
|
|
198
200
|
yield AckableMessage(
|
|
199
201
|
data=msg[b"data"],
|
|
200
|
-
ack=self._ack_generator(msg_id),
|
|
202
|
+
ack=self._ack_generator(id=msg_id, queue_name=stream),
|
|
201
203
|
)
|
|
@@ -230,19 +230,20 @@ class RedisStreamSentinelBroker(BaseSentinelBroker):
|
|
|
230
230
|
|
|
231
231
|
:param message: message to append.
|
|
232
232
|
"""
|
|
233
|
+
queue_name = message.labels.get("queue_name") or self.queue_name
|
|
233
234
|
async with self._acquire_master_conn() as redis_conn:
|
|
234
235
|
await redis_conn.xadd(
|
|
235
|
-
|
|
236
|
+
queue_name,
|
|
236
237
|
{b"data": message.message},
|
|
237
238
|
maxlen=self.maxlen,
|
|
238
239
|
approximate=self.approximate,
|
|
239
240
|
)
|
|
240
241
|
|
|
241
|
-
def _ack_generator(self, id: str) -> Callable[[], Awaitable[None]]:
|
|
242
|
+
def _ack_generator(self, id: str, queue_name: str) -> Callable[[], Awaitable[None]]:
|
|
242
243
|
async def _ack() -> None:
|
|
243
244
|
async with self._acquire_master_conn() as redis_conn:
|
|
244
245
|
await redis_conn.xack(
|
|
245
|
-
|
|
246
|
+
queue_name,
|
|
246
247
|
self.consumer_group_name,
|
|
247
248
|
id,
|
|
248
249
|
)
|
|
@@ -263,10 +264,10 @@ class RedisStreamSentinelBroker(BaseSentinelBroker):
|
|
|
263
264
|
block=self.block,
|
|
264
265
|
noack=False,
|
|
265
266
|
)
|
|
266
|
-
for
|
|
267
|
+
for stream, msg_list in fetched:
|
|
267
268
|
for msg_id, msg in msg_list:
|
|
268
269
|
logger.debug("Received message: %s", msg)
|
|
269
270
|
yield AckableMessage(
|
|
270
271
|
data=msg[b"data"],
|
|
271
|
-
ack=self._ack_generator(msg_id),
|
|
272
|
+
ack=self._ack_generator(id=msg_id, queue_name=stream),
|
|
272
273
|
)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: taskiq-redis
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
4
4
|
Summary: Redis integration for taskiq
|
|
5
|
+
License-File: LICENSE
|
|
5
6
|
Keywords: taskiq,tasks,distributed,async,redis,result_backend
|
|
6
7
|
Author: taskiq-team
|
|
7
8
|
Author-email: taskiq@norely.com
|
|
@@ -13,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
18
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
19
|
Classifier: Programming Language :: Python :: 3.8
|
|
18
20
|
Requires-Dist: redis (>=6,<7)
|
|
@@ -213,3 +215,17 @@ scheduler = TaskiqScheduler(broker, [array_source])
|
|
|
213
215
|
|
|
214
216
|
During startup the scheduler will try to migrate schedules from an old source to a new one. Please be sure to specify different prefixe just to avoid any kind of collision between these two.
|
|
215
217
|
|
|
218
|
+
|
|
219
|
+
## Dynamic queue names
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
Brokers supports dynamic queue names, allowing you to specify different queues when kicking tasks. This is useful for routing tasks to specific queues based on runtime conditions, such as priority levels, tenant isolation, or environment-specific processing.
|
|
223
|
+
|
|
224
|
+
Simply pass the desired queue name as message's label when kicking a task to override the broker's default queue configuration.
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
@broker.task(queue_name="low_priority")
|
|
228
|
+
async def low_priority_task() -> None:
|
|
229
|
+
print("I don't mind waiting a little longer")
|
|
230
|
+
```
|
|
231
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
taskiq_redis/__init__.py,sha256=Sl4m9rKxweU1t0m289Qtf0qm4xSSkkFHoOfKq6qaz6g,1192
|
|
2
|
+
taskiq_redis/exceptions.py,sha256=7buBJ7CRVWd5WqVqSjtHO8cVL7QzZg-DOM3nB87t-Sk,738
|
|
3
|
+
taskiq_redis/list_schedule_source.py,sha256=aMM_LCJrbg2GIb8BTJJEZaFIWxziR68TwGELMTKI1q8,9805
|
|
4
|
+
taskiq_redis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
taskiq_redis/redis_backend.py,sha256=sE4XeGr1fX0IE5FBdCJ9uP6DH7khAKlt8va2SwTv4go,19850
|
|
6
|
+
taskiq_redis/redis_broker.py,sha256=COVKtKTy9JTqwwKr0FY4DGbv_CU1aEcYa0hrZNbvQpc,12339
|
|
7
|
+
taskiq_redis/redis_cluster_broker.py,sha256=Kcp2bsrarEcwDfrPnk52iiEpT5HOdnrCbeT79i0xNgY,7271
|
|
8
|
+
taskiq_redis/redis_sentinel_broker.py,sha256=D3EVc2-mpOayU8IYvqeBeGJxNr1rBX4ElQrU0R-CJoA,9705
|
|
9
|
+
taskiq_redis/schedule_source.py,sha256=mDYlAlAuzIzMICpJiQ1AwWOF-9_OHVGJWXA45Gm2Trg,10128
|
|
10
|
+
taskiq_redis-1.1.2.dist-info/METADATA,sha256=ln415QqFA3Il9AfBx-htyw0KhCdLDYHCipJExCihfLg,7205
|
|
11
|
+
taskiq_redis-1.1.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
12
|
+
taskiq_redis-1.1.2.dist-info/licenses/LICENSE,sha256=lEHEEE-ZxmuItxYgUMPiFWdRcAITxE8DFMNyAg4eOYE,1075
|
|
13
|
+
taskiq_redis-1.1.2.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
taskiq_redis/__init__.py,sha256=Sl4m9rKxweU1t0m289Qtf0qm4xSSkkFHoOfKq6qaz6g,1192
|
|
2
|
-
taskiq_redis/exceptions.py,sha256=7buBJ7CRVWd5WqVqSjtHO8cVL7QzZg-DOM3nB87t-Sk,738
|
|
3
|
-
taskiq_redis/list_schedule_source.py,sha256=aMM_LCJrbg2GIb8BTJJEZaFIWxziR68TwGELMTKI1q8,9805
|
|
4
|
-
taskiq_redis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
taskiq_redis/redis_backend.py,sha256=sE4XeGr1fX0IE5FBdCJ9uP6DH7khAKlt8va2SwTv4go,19850
|
|
6
|
-
taskiq_redis/redis_broker.py,sha256=WNiQOrekllNlAIHLknwEGUBNoUGqATCni2vQ3d8a5To,12207
|
|
7
|
-
taskiq_redis/redis_cluster_broker.py,sha256=27Qr4y0GNrcx4h35TbE9pCWiB8oOv9ON2st7EXqh1zY,7096
|
|
8
|
-
taskiq_redis/redis_sentinel_broker.py,sha256=4aBTM2L-iYpAej4yasQJbocH0koV4wZ_US_-COTfkK8,9598
|
|
9
|
-
taskiq_redis/schedule_source.py,sha256=mDYlAlAuzIzMICpJiQ1AwWOF-9_OHVGJWXA45Gm2Trg,10128
|
|
10
|
-
taskiq_redis-1.1.0.dist-info/LICENSE,sha256=lEHEEE-ZxmuItxYgUMPiFWdRcAITxE8DFMNyAg4eOYE,1075
|
|
11
|
-
taskiq_redis-1.1.0.dist-info/METADATA,sha256=QChMA4jQQZAAHoqcKLNjtd972XHyHNGlOmq9O7fbijw,6573
|
|
12
|
-
taskiq_redis-1.1.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
13
|
-
taskiq_redis-1.1.0.dist-info/RECORD,,
|
|
File without changes
|