Public | Automated Build

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

#Work In Progress

Please understand this is a work in progress, you may wish to play around with it, just to get a feel of what it will do.

Want to tinker? Then click here:

Introduction

Work Queue

The idea behind this container is to provide a very simple work queue driven by the HTTP protocol. You make requests of this container to make requests upon another service, however execution of these requests are moderated by a work queue (see Task Spooler for the underlying mechanism)

It is usually called from a linked container using:

curl http://${QUEUE_PORT_8080_TCP_ADDR}:${QUEUE_PORT_8080_TCP_PORT}/execute/google.com/?q=hello

In this simple example we are requesting execution of a GET method on http://google.com/?=hello on the work queue and we want to get the result synchronously.

Or we could queue the execution using:

curl http://${QUEUE_PORT_8080_TCP_ADDR}:${QUEUE_PORT_8080_TCP_PORT}/enqueue/google.com/?q=hello

This returns the queue id of the request, which can be used to see the result at a later time.

Sample Code

#!/usr/bin/env bash
set -ex
prefix="http://${QUEUE_PORT_8080_TCP_ADDR}:${QUEUE_PORT_8080_TCP_PORT}"
task1=$(curl ${prefix}/enqueue/google.com/?q=test)
curl ${prefix}/queue/${task1}/wait
assert1=$(curl --silent --output /dev/stdout--write-out "%{http_code}" ${prefix}/queue/${task1}/assert/HTML| cut -d' ' -f1)
(($assert1 == 200))

out1=$(curl ${prefix}/queue/${task1}/stdout)
err1=$(curl ${prefix}/queue/${task1}/stderr)

The above is an example of how you use http-workqueue, it actually comes from the test script. Here you see a task being queued, the request will be made to "http://google.com/?q=test"

task1=$(curl ${prefix}/enqueue/google.com/?q=test)

We then wait for it to be executed

curl ${prefix}/queue/${task1}/wait

Of course we can be busy doing something else at this time. Next we assert that the text 'HTML' is within the body of the result and get the HTTP code returned to check to see if it's 200 (it will be 404 if the assertion failed)

assert1=$(curl --silent --output /dev/stdout --write-out "%{http_code}" ${prefix}/queue/${task1}/assert/HTML| cut -d' ' -f1)
(($assert1 == 200))

Finally we request the stdout and stderr of the command:

out1=$(curl ${prefix}/queue/${task1}/stdout)
err1=$(curl ${prefix}/queue/${task1}/stderr)

API Reference

Is currently being built on Apiary.io at http://docs.httpworkqueue.apiary.io/

Planned Work

(We use waffle.io for planning: )

The core aim of this service is to support three functions:

1) Execute/Queue work on a work queue (based on ts) [ active development ]

2) Schedule work at a given time (based on at) [ started ]

3) Schedule repeated work (based on cron) [ started ]

And to demonstrate that we really do forget how to KISS

Docker Pull Command
Owner
sillelien
Source Repository

Comments (0)