Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Sehat1137/litestar-dishka-faststream
Template for litestar+dishka+faststream
https://github.com/Sehat1137/litestar-dishka-faststream
Last synced: 2 months ago
JSON representation
Template for litestar+dishka+faststream
- Host: GitHub
- URL: https://github.com/Sehat1137/litestar-dishka-faststream
- Owner: Sehat1137
- License: mit
- Created: 2024-03-10T18:47:13.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-06-10T14:35:17.000Z (7 months ago)
- Last Synced: 2024-08-03T17:12:40.447Z (5 months ago)
- Language: Python
- Size: 15.6 KB
- Stars: 22
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-litestar - Litestar, FastStream, dishka, SQLAlchemy
README
# litestar-dishka-faststream
This project is an implementation of "Clean architecture" in Python.
### Running the project
Install dependencies
```shell
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```Run containers with rabbitMQ and PostgreSQL
```
cp .env.dist .env
docker compose up -d
```Run migrations and creare queue
```shell
export $(grep -v '^#' .env | xargs)
alembic upgrade head
docker exec -it book-club-rabbitmq rabbitmqadmin -u $RABBITMQ_USER -p $RABBITMQ_PASS -V / declare queue name=create_book durable=false
docker exec -it book-club-rabbitmq rabbitmqadmin -u $RABBITMQ_USER -p $RABBITMQ_PASS -V / declare queue name=book_statuses durable=false
```Run the project
```shell
export $(grep -v '^#' .env | xargs)
uvicorn --factory book_club.main:get_app --reload
```Workflow
```shell
export $(grep -v '^#' .env | xargs)
// Publish message
docker exec -it book-club-rabbitmq rabbitmqadmin -u $RABBITMQ_USER -p $RABBITMQ_PASS \
publish exchange=amq.default routing_key=create_book payload='{"title": "The Brothers Karamazov", "pages": 928, "is_read": true}'// Read uuid of created book
docker exec -it book-club-rabbitmq rabbitmqadmin -u $RABBITMQ_USER -p $RABBITMQ_PASS get queue=book_statuses count=1// Get book info by http api
curl http://localhost:8000/book/{uuid}
```Run only http
```shell
export $(grep -v '^#' .env | xargs)
uvicorn --factory book_club.main:get_litestar_app --reload
```Run only amqp
```shell
export $(grep -v '^#' .env | xargs)
faststream run --factory book_club.main:get_faststream_app --reload
```