Skip to content

Create a job queue whose workers fetch data from a URL and store the results in a database. The job queue should expose a REST API for adding jobs and checking their status / results.

Notifications You must be signed in to change notification settings

cmalagar/jobQueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Job Queue API

Create a job queue whose workers fetch data from a URL and store the results in a database. The job queue should expose a REST API for adding jobs and checking their status / results.

Build Setup

Install dependencies:

$ npm install

Please ensure that you have MongoDB and Redis installed and running before starting the server.

Start the server:

$ npm start

Server should be started on port 3000.

API Endpoints

POST /jobs

Create a new job

Example request:

POST /jobs
Content-Type: application/json

{"url": "http://www.google.com"}

Example Successful Response:

{
	"id": "59a6a8559a77502060e6adf0",
	"status": "pending",
	"timestamp": "2017-08-30T11:58:13.371Z",
	"url": "http://www.google.com"
}

GET /jobs/:jobId

Read a job using it's job ID

Example request:

GET /jobs/59a644cf91257c071849eae

Example Successful Response With Completed Job:

HTTP 200 OK
Content-Type: application/json
{
    "_id": "59a644cf91257c071849eae5",
    "url": "http://www.google.com",
    "timestamp": "2017-08-30T04:53:35.984Z",
    "status": "completed",
    "response": "<!doctype html><html>...</html>"
}

Example Successful Response with Pending/Ongoing Job:

HTTP 200 OK
Content-Type: application/json
{
	"_id": "59a644cf91257c071849eae5",
	"url": "http://www.google.com",
	"timestamp": "2017-08-30T04:53:35.984Z",
	"status": "pending" OR "ongoing"
}

About

Create a job queue whose workers fetch data from a URL and store the results in a database. The job queue should expose a REST API for adding jobs and checking their status / results.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published