Skip to content

Commit fe351ff

Browse files
authored
Merge pull request #20 from taskiq-python/feat-rewrite-broker-with-aioboto
feat: implement broker with aiobotocore
2 parents 4349d0e + cd021e4 commit fe351ff

15 files changed

Lines changed: 378 additions & 407 deletions

.github/workflows/code-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
matrix:
3030
os: [ubuntu-latest] # eventually add `windows-latest` and `macos-latest`
31-
python-version: ["3.10", "3.11", "3.12"]
31+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
3232
services:
3333
ministack:
3434
image: ministackorg/ministack:1.3.53

docker-compose.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,6 @@ services:
2222
networks:
2323
- taskiq-sqs-network
2424

25-
redis:
26-
image: bitnamilegacy/redis:7.4.2
27-
environment:
28-
ALLOW_EMPTY_PASSWORD: "yes" # pragma: allowlist secret
29-
healthcheck:
30-
test: ["CMD", "redis-cli", "ping"]
31-
interval: 5s
32-
timeout: 5s
33-
retries: 3
34-
start_period: 10s
35-
ports:
36-
- 6379:6379
37-
3825
networks:
3926
taskiq-sqs-network:
4027
driver: bridge

examples/example_broker.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,51 @@
88

99
import asyncio
1010

11-
import boto3
1211
import dotenv
12+
from aiobotocore.session import get_session
1313

1414
from taskiq_sqs import S3Bucket, S3ResultBackend, SQSBroker
1515

1616

1717
dotenv.load_dotenv()
1818

1919
QUEUE_NAME = "my-queue"
20-
QUEUE_URL = f"http://localhost:4566/000000000000/{QUEUE_NAME}"
21-
22-
23-
boto3.client("sqs").create_queue(QueueName=QUEUE_NAME)
24-
25-
broker = SQSBroker(QUEUE_URL, sqs_region_override="us-east-1").with_result_backend(
26-
S3ResultBackend(bucket=S3Bucket(name="response-bucket"))
20+
ENDPOINT_URL = "http://localhost:4566"
21+
AWS_REGION = "us-east-1"
22+
23+
24+
broker = SQSBroker(
25+
queue_name=QUEUE_NAME,
26+
endpoint_url=ENDPOINT_URL,
27+
aws_region_name=AWS_REGION,
28+
).with_result_backend(
29+
S3ResultBackend(
30+
bucket=S3Bucket(name="response-bucket"),
31+
endpoint_url=ENDPOINT_URL,
32+
aws_region_name=AWS_REGION,
33+
),
2734
)
2835

2936

3037
@broker.task()
3138
async def i_love_aws() -> None:
3239
"""I hope my cloud bill doesn't get too high!"""
33-
await asyncio.sleep(5.5)
40+
await asyncio.sleep(2)
3441
print("Hello there!")
3542

3643

44+
async def ensure_queue_exists() -> None:
45+
session = get_session()
46+
async with session.create_client(
47+
"sqs",
48+
region_name=AWS_REGION,
49+
endpoint_url=ENDPOINT_URL,
50+
) as sqs:
51+
await sqs.create_queue(QueueName=QUEUE_NAME)
52+
53+
3754
async def main() -> None:
55+
await ensure_queue_exists()
3856
await broker.startup()
3957
task = await i_love_aws.kiq()
4058
print(await task.wait_result())

pyproject.toml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
name = "taskiq-sqs"
33
version = "0.0.11"
44
description = "SQS Broker for TaskIQ"
5-
urls = {source = "https://github.com/taskiq-python/taskiq-sqs"}
65
readme = "README.md"
76
licence = "MIT"
87
license = {file = "LICENSE"}
@@ -32,14 +31,13 @@ keywords = ["taskiq", "broker", "aws", "sqs"]
3231
requires-python = ">=3.10"
3332
dependencies = [
3433
"taskiq>=0.12.1",
35-
"asyncer~=0.0.5",
36-
"boto3~=1.34.34",
3734
"aiobotocore>=2.13.3",
3835
]
3936

40-
# [project.urls]
41-
# "Bug Tracker" = "https://github.com/taskiq-python/taskiq-sqs/issues"
42-
# "Repository" = "https://github.com/taskiq-python/taskiq-sqs/"
37+
[project.urls]
38+
"Source" = "https://github.com/taskiq-python/taskiq-sqs"
39+
"Bug Tracker" = "https://github.com/taskiq-python/taskiq-sqs/issues"
40+
"Repository" = "https://github.com/taskiq-python/taskiq-sqs/"
4341

4442
[dependency-groups]
4543
dev = [
@@ -59,8 +57,6 @@ lint = [
5957
]
6058
types = [
6159
"mypy>=2.1.0",
62-
"mypy-boto3-sqs>=1.34.101",
63-
"boto3-stubs[essential]>=1.34.84",
6460
"types-aiobotocore[essential]>=3.7.0",
6561
]
6662
examples = [

src/taskiq_sqs/aws.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)