Cab Booking Distributed Python Service
https://docs.docker.com/engine/install/
https://www.python.org/downloads/
pip3 install -r requirements.txt
Setup authentication using the below link and store environment variables in a .env file.
https://github.com/conductor-sdk/conductor-python?tab=readme-ov-file#setup-sdk
This app has 6 components:
- Flask server that servers the booking endpoint to trigger booking workflow
- Booking Service
- Assignment Service
- Payment Service
- Notification Service
- Workflow definition creation script
python3 workflows.py
python3 main.py
docker compose up
python3 workers.py
curl --location 'http://127.0.0.1:5000/booking' \
--header 'Content-Type: application/json' \
--data '{
"pickUpLocation": "15 Mark Chester Pl, Chicago, IL 12045",
"dropOffLocation": "64 West 21st Street, Chicago, IL 13012",
"riderId": 1
}'
To simulate a distributed rollback in a Saga based microservice architecture, we make the payment fail for all riders with id > 2 which leads to terminate the main workflow and trigger a failure workflow.
curl --location 'http://127.0.0.1:5000/booking' \
--header 'Content-Type: application/json' \
--data '{
"pickUpLocation": "15 Mark Chester Pl, Chicago, IL 12045",
"dropOffLocation": "64 West 21st Street, Chicago, IL 13012",
"riderId": 3
}'