Examples¶
Runnable projects live in examples/ in the repository. CI runs each example's tests against the package from the same commit, so they keep working; the Docker images install the matching release from PyPI.
FastAPI¶
examples/fastapi: an order service.
POST /orderswrites the order and enqueuesorders.confirmin one transaction: a failed request leaves neither.- The worker confirms the order and enqueues
orders.receipton queuemailin the transaction that marks the jobsucceeded(complete_tx). setup_db.pyis the deploy step:migrate, then the app's own tables.test_example.pydrives the API withhttpxand runs the jobs withdrain.compose.ymlstarts Postgres, the setup step, the API and a worker on both queues.
cd examples/fastapi
docker compose up --build
curl -X POST localhost:8000/orders -H 'content-type: application/json' -d '{"email": "ada@example.com"}'
curl localhost:8000/orders/1