A distributed ticket sale system allows users to purchase tickets to travel from destination A to B, potentially using combinations (connections) of services from different companies. Each company offers a set of services between various locations, each with a defined capacity (number of seats).
Additionally, each company operates its own node (server) that processes requests in the following form:
getFreeSeats(serviceId)
reserve(serviceId, seat_number)
confirm_reserve(serviceId, seat_number)
cancel_reserve(serviceId, seat_number)
The goal is to design and implement a system that prevents ticket overselling.
Create a virtual environment:
python3 -m venv envActivate the virtual environment:
source env/bin/activateInstall the requirements:
pip install -r requirements.txtRun airline servers on different terminals to see the logs:
python3 run_airline_server.py -i resources/aerolineas_argentinas.json
python3 run_airline_server.py -i resources/latam_airlines.json
python3 run_airline_server.py -i resources/qatar_airways.json
python3 run_airline_server.py -i resources/american_airlines.json
python3 run_airline_server.py -i resources/flybondi.jsonRun ticket service servers on different terminals to see the logs:
python3 run_ticket_service_server.py -i resources/despegarcito1.json
python3 run_ticket_service_server.py -i resources/despegarcito2.json
python3 run_ticket_service_server.py -i resources/despegarcito3.json
python3 run_ticket_service_server.py -i resources/despegarcito4.jsonRun the client (Default port servers ar running from 8001 to 8004):
python3 client.py -a localhost:<some_port>python -m grpc_tools.protoc -I protos/ --python_out=networking/ticket_service/ --pyi_out=networking/ticket_service --grpc_python_out=networking/ticket_service/ protos/ticket_service.proto
python -m grpc_tools.protoc -I protos/ --python_out=networking/airline/ --pyi_out=networking/airline/ --grpc_python_out=networking/airline protos/airline_service.proto