File tree Expand file tree Collapse file tree 1 file changed +63
-1
lines changed Expand file tree Collapse file tree 1 file changed +63
-1
lines changed Original file line number Diff line number Diff line change 1- ## TaskIQ-Redis
1+ # TaskIQ-Redis
2+
3+ Taskiq-redis is a plugin for taskiq that adds a new broker and result backend based on redis.
4+
5+ # Installation
6+
7+ To use this project you must have installed core taskiq library:
8+ ``` bash
9+ pip install taskiq
10+ ```
11+ This project can be installed using pip:
12+ ``` bash
13+ pip install taskiq-redis
14+ ```
15+
16+ # Usage
17+
18+ Let's see the example with the redis broker and redis async result:
19+ ``` python
20+ import asyncio
21+
22+ from taskiq_redis.redis_broker import RedisBroker
23+ from taskiq_redis.redis_backend import RedisAsyncResultBackend
24+
25+
26+ redis_async_result = RedisAsyncResultBackend(
27+ url = " redis://localhost:6379" ,
28+ )
29+
30+ broker = RedisBroker(
31+ url = " redis://localhost:6379" ,
32+ result_backend = redis_async_result,
33+ )
34+
35+
36+ @broker.task
37+ async def best_task_ever () -> None :
38+ """ Solve all problems in the world."""
39+ await asyncio.sleep(5.5 )
40+ print (" All problems are solved!" )
41+
42+
43+ async def main ():
44+ task = await my_async_task.kiq()
45+ print (await task.get_result())
46+
47+
48+ asyncio.run(main())
49+ ```
50+
51+ ## RedisBroker configuration
52+
53+ RedisBroker parameters:
54+ * ` url ` - url to redis.
55+ * ` task_id_generator ` - custom task_id genertaor.
56+ * ` result_backend ` - custom result backend.
57+ * ` queue_name ` - name of the pub/sub channel in redis.
58+ * ` max_connection_pool_size ` - maximum number of connections in pool.
59+
60+ ## RedisAsyncResultBackend configuration
61+
62+ RedisAsyncResultBackend parameters:
63+ * ` url ` - url to redis.
You can’t perform that action at this time.
0 commit comments