Skip to content

Commit 9d19398

Browse files
authored
Merge pull request #8 from Ifechukwu001/feat/rabbitmq
Fixed to use Faststream for an easier flow
2 parents f18e3cd + ece528c commit 9d19398

File tree

6 files changed

+427
-161
lines changed

6 files changed

+427
-161
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ The Swagger documentation for the application is hosted on [Render](https://df-a
4444
- Run the server locally on port 8000
4545

4646
```bash
47-
uv run manage.py runserver 8000
47+
uv run uvicorn src.config.asgi:application --reload --port 8000
4848
```

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ dependencies = [
2020
"django-ninja>=1.3.0",
2121
"pyjwt>=2.10.1",
2222
"pika>=1.3.2",
23+
"faststream[rabbit]>=0.5.39",
24+
"starlette>=0.46.2",
25+
"uvicorn>=0.34.1",
2326
]
2427

2528
[dependency-groups]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/api/services/external/RabbitMQService.py

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

src/config/asgi.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@
1010
import os
1111

1212
from django.core.asgi import get_asgi_application
13+
from faststream.rabbit import RabbitBroker
14+
from starlette.routing import Mount
15+
from starlette.applications import Starlette
16+
17+
from src.env import rabbitmq_config
18+
19+
broker = RabbitBroker(host=rabbitmq_config["host"])
20+
1321

1422
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "src.config.settings")
1523

16-
application = get_asgi_application()
24+
application = Starlette(
25+
routes=[Mount("/", get_asgi_application())], # type: ignore
26+
on_startup=[broker.start],
27+
on_shutdown=[broker.close],
28+
)
29+
30+
31+
from src.api.services.external import RabbitMQRoutes as RabbitMQRoutes # noqa: E402

0 commit comments

Comments
 (0)