A simple FIFO API Gateway for managing API calls, storing them in MySQL, and processing in order.
Python 3.x
,Flask
,MySQL
,pip
Instructions for Production Deployment found Here.
-
Create a
MySQL
User and Database onMySQL 8
or better.CREATE DATABASE IF NOT EXISTS api_gateway_fifo; CREATE USER IF NOT EXISTS 'api_gateway'@'%' IDENTIFIED BY 'your_mysql_password'; GRANT ALL PRIVILEGES ON api_gateway_fifo.* TO 'api_gateway'@'%'; FLUSH PRIVILEGES;
-
Clone Repository:
git clone https://github.com/appatalks/fifo_api_gateway_server.git cd api_fifo_limiter
-
Install Dependencies:
pip install flask mysql-connector-python
-
Initialize MySQL Database:
python fifo_init.py
- Start Server
python api_fifo_server.py
- Direct API to Server Endpoint
curl -k -X POST https://127.0.0.1:5000/api/save -H "Content-Type: application/json" -d '{"data": "example data"}'
- Retrieve from MySQL and Delete Data;
curl -k -X GET https://127.0.0.1:5000/api/deliver
(Use valid certificates
, otherwise accept self-signed
as valid with curl -k
flag)
- Use Case: Applications that need to manage background tasks.
- Benefit: Ensures tasks are processed in the order they were received.
- Use Case: Managing job scheduling systems.
- Benefit: Ensures jobs are executed in a specific order.
- Example: Regularly process queued request in-line with endpoint
ratelimit
gates.
- Use Case: Serving as an event logging system.
- Benefit: Events are stored and processed in the order they occur.
- Use Case: Data analytics pipelines.
- Benefit: Processes data in the sequence it was received to maintain temporal consistency.