zerovm/zerocloud — pull request #42 by pkit (2014-04-23 00:56:24+00:00)
Title: implement deferred response for longer jobs

introducing a new header `x-zerovm-deferred`
can be `never`, `auto` or `always`

`never` (default behavior)
will support the legacy use case
which means that results of any jobs will be returned in the response body and headers, regardless of how much time the response will take
if one of the timeouts fires up, the results of a job my be lost

`always`
results will always be deferred, which means that after the job was successfully submitted to object servers the response will be immediately returned to user
the response body will contain Swift URL of the object that user needs to poll, and the results will appear in that object
Swift URL will be of the form: `swift://account/container/object`

If user submitted a POST request to `/v1/a1/c1/o1` the deffred response results will appear under `swift://a1/c1/o1`
If submitted to `/v1/a` (default case) the deffered object URL will be auto-generated.

`auto`
if there is `interactive_timeout` configuration variable configured for proxyquery middleware the value of that variable will be used for the timeout
if response will arrive before `interactive_timeout` the response data and headers will be sent immediately to the user
if `interactive_timeout` passes then deferred object URL will be sent to user in the response body and the results will be placed under that object

if `interactive_timeout` is not configured the value will be the same as `node_timeout` and the behavior of `auto` will be the same as `never`

if the response is deferred the `swift://account/container/object` URL will contain the body of the response
another object will be also created `swift://account/container/object.headers` and it will contain all the headers of the response (serialized to JSON)

if your job produses a lot of headers and it's hard to manage them
you can set the job to `always` and then headers will be placed into Swift object that can be parsed and queried separately