File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # TaskIQ SQS Broker
1+ # taskiq-sqs
22
3- Mostly generic SQS async broker for TaskIQ.
3+ [ ![ PyPI - Python Version] ( https://img.shields.io/pypi/pyversions/taskiq-sqs?style=for-the-badge&logo=python )] ( https://pypi.org/project/taskiq-sqs/ )
4+ [ ![ PyPI] ( https://img.shields.io/pypi/v/taskiq-sqs?style=for-the-badge&logo=pypi )] ( https://pypi.org/project/taskiq-sqs/ )
5+ [ ![ Checks] ( https://img.shields.io/github/check-runs/taskiq-python/taskiq-sqs/main?nameFilter=test%20(ubuntu-latest,%203.12)&style=for-the-badge )] ( https://github.com/taskiq-python/taskiq-sqs )
46
5- ## Expiration
7+ This library provides SQS broker and S3 result backend for TaskIQ.
8+
9+ ## Installation
10+
11+ ``` bash
12+ pip install taskiq-sqs
13+ ```
14+
15+ ## Basic usage
16+
17+ Here is an example of how to use the SQS broker with the S3 backend:
18+
19+ ``` python
20+ import asyncio
21+ from taskiq_sqs import S3Bucket, S3ResultBackend, SQSBroker
22+
23+ QUEUE_NAME = " my-queue"
24+ broker = SQSBroker(
25+ " http://localhost:4566/000000000000/my-queue" , # specify existing queue
26+ sqs_region_override = " us-east-1"
27+ ).with_result_backend(
28+ S3ResultBackend(
29+ bucket = S3Bucket(name = " response-bucket" ) # by default backend will create bucket for your if it not exists
30+ )
31+ )
32+
33+ @broker.task ()
34+ async def i_love_aws () -> None :
35+ await asyncio.sleep(1 )
36+ print (" Hello there!" )
37+
38+ async def main () -> None :
39+ await broker.startup()
40+ task = await i_love_aws.kiq()
41+ print (await task.wait_result())
42+ await broker.shutdown()
43+
44+ if __name__ == " __main__" :
45+ asyncio.run(main())
46+ ```
47+
48+ How to run:
49+ - run worker first with ` taskiq worker examples.example_broker:broker `
50+ - after that run broker to create a task and wait for result: ` python examples/example_broker.py `
51+
52+ ## Message expiration
653
754If you set the ` sqs_expiry ` label to a unix timestamp, the message will be discarded if the worker receives it after that time.
855
You can’t perform that action at this time.
0 commit comments