# clone the source code from github
git clone https://github.com/plivo/sharq-server.git
# create a virtual environment.
virtualenv venv && source ./venv/bin/active
# in the project root directory.
make build && make install
SharQ server exposes the sharq-server command.
usage: sharq-server [-h] -c SHARQ_CONFIG [-gc GUNICORN_CONFIG] [--version]
SharQ Server!
optional arguments:
-h, --help show this help message and exit
-c SHARQ_CONFIG, --config SHARQ_CONFIG
Absolute path of the SharQ configuration file.
-gc GUNICORN_CONFIG, --gunicorn-config GUNICORN_CONFIG
Gunicorn configuration file.
--version show program's version number and exit
SharQ server can be started with the following command. A simple SharQ config file can be found here.
$sharq-server --config sharq.conf
Ensure the SharQ server is up by making a HTTP request.
$curl http://127.0.0.1:8080/
{
"message": "Hello, SharQ!"
}
POST /enqueue/<queue_type>/<queue_id>/
Request (Raw JSON POST data):
{
"job_id": "b81c07a7-5bba-4790-ab40-a061994088c1",
"interval": 1000,
"payload": {"hello": "world"}
}
Response (success):
Status Code: 201
{
"status": "queued"
}
Response (bad request):
Status Code: 400
{
"message": "`queue_type` is a mandatory parameter",
"status": "failure"
}
cURL Example:
$curl -H "Accept: application/json" \
-H "Content-type: application/json" \
-X POST -d ' {"job_id": "b81c07a7-5bba-4790-ab40-a061994088c1", "interval": 1000, "payload": {"hello": "world"}}' \
http://localhost:8080/enqueue/sms/1/
GET /dequeue/<queue_type>/
Response (success):
Status Code: 200
{
"job_id": "b81c07a7-5bba-4790-ab40-a061994088c1",
"payload": {
"hello": "world"
},
"queue_id": "1",
"status": "success"
}
Response (queue has no job ready):
Status Code: 404
{
"status": "failure"
}
Response (bad request): Status Code: 400
{
"message": "`queue_type` has an invalid value.",
"status": "failure"
}
cURL Example:
curl http://localhost:8080/dequeue/sms/
POST /finish/<queue_type>/<queue_id>/<job_id>/
Response (success):
Status Code: 200
{
"status": "success"
}
Response (bad request):
Status Code: 400
{
"message": "`queue_id` is a mandatory parameter",
"status": "failure"
}
cURL Example:
curl -X POST http://localhost:8080/finish/sms/1/b81c07a7-5bba-4790-ab40-a061994088c1/