Homework about distributed systems.
More documentation in DOCS.md
-
Required software
- Python 3.9 or higher
- Docker Desktop
- Python Poetry
-
Start the app for development (with auto reload enabled)
docker compose up
-
After application start, database is refreshed with test data from scripts/initial_data.py
- Available
campaign_id
- 1 and 2 - Generated 10'000 discount codes for each campaign.
- Available
-
Start the app with gunicorn for concurrency testing (production mode)
docker compose -f docker-compose.gunicorn.yml up
-
(optional) To run auto tests with
pytest
, additionally install dependencies locally with Poetry- Update global Python packages
python -m pip install -U pip wheel setuptools
- Install dependencies
poetry install
- Activate Python virtual environment
poetry shell
- Install pre-commit hooks
pre-commit install
- Helper commands from scripts/dev_commands.py
poetry run format/lint/test/test_cov_term/test_cov_html/test_ci
- Run all hooks at once
poetry run hooks
- Documentation
- How to start the app
- Presentation
- Fetch a discount code
- POST, 201
- GET 200
- is_used flag
- 404 if campaign does not exist
- Authentication with fake JWT like token
- Decouple business logic from Flask route
- SELECT FOR UPDATE SKIP LOCKED for concurrent selects
- Send callback to the brand that code has been created
- Generate a discount code. Brand wants to create X number of discount codes
- Generate job ID and simulate as if job was placed to the queue
- Create discounts codes asynchronously
- Route for polling job status <-- not doing now