LeanQueue is a Node.js application designed to manage task queues. It uses Express as a web framework and PostgreSQL for data storage.
- Queue Management: Create and manage task queues dynamically.
- Task Handling: Add tasks to queues and retrieve them for processing.
- Result Submission: Submit results for completed tasks.
- Node.js - JavaScript runtime.
- Express - Web framework for Node.js.
- PostgreSQL - Open-source relational database.
-
Clone the repository: Owner avatar Lean-Queue
git clone https://github.com/vixhnuchandran/Lean-Queue cd Lean-Queue
-
Install dependencies:
pnpm install
-
Create a
.env
file in the project root and define the following environment variables:POSTGRES_URL=your_postgres_database_url
Adjust
your_postgres_database_url
with your PostgreSQL database URL.
Run the application using nodemon:
pnpm start
-
Create Queue API request: Create a new task queue with specified type and tasks.
POST /create-queue body: { "type": "addition", "tasks": [ { "taskId": "5001", "params": { "num1": 3, "num2": 56 }, "priority": 7 }, { "taskId": "5002", "params": { "num1": 63, "num2": 45 }, "priority": 7 }, { "taskId": "5003", "params": { "num1": 44, "num2": 98 }, "priority": 7 }, . . { "taskId": "5179", "params": { "num1": 48, "num2": 95 }, "priority": 7 }, { "taskId": "5180", "params": { "num1": 26, "num2": 11 }, "priority": 7 }, { "taskId": "5181", "params": { "num1": 60, "num2": 39 }, "priority": 7 } ], "tags": ["arithmetic", "dev"], "options": { "expiryTime": 150000, "callback": "https://sample.url" } }
-
Add Tasks to Queue: Add tasks to an existing queue.
POST /add-tasks body: { "queue": 4, "tasks": [ { "taskId": "5001", "params": { "num1": 3, "num2": 56 }, "priority": 7 }, { "taskId": "5002", "params": { "num1": 63, "num2": 45 }, "priority": 7 }, { "taskId": "5003", "params": { "num1": 44, "num2": 98 }, "priority": 7 }, . . { "taskId": "5179", "params": { "num1": 48, "num2": 95 }, "priority": 7 }, { "taskId": "5180", "params": { "num1": 26, "num2": 11 }, "priority": 7 }, { "taskId": "5181", "params": { "num1": 60, "num2": 39 }, "priority": 7 } ], }
-
Get Available Tasks: Get the next available task from the specified queue or type.
POST /get-available-tasks body: { {'type': 'addition'} or {'queue': 1} or {'tags': ['arithmetic', 'dev']} }
-
Submit Results: Submit the results of a task, marking it as completed or with an error.
POST /submit-results body: { {'id': 22, 'result': 167, 'error': None} }
-
Queue Status: Retrieve the status of a queue, including total tasks count, completed tasks, and tasks with errors.
GET /status/<queueId>
-
Queue Result: Retrieve the results of completed tasks and tasks with errors for a specific queue.
GET /get-results/<queueId>
python worker.py --using type --value addition
python worker.py --using queue --value 1
python worker.py --using tags --value '["arithmetic", "dev"]'
This project is licensed under the MIT License