Skip to content
Fabien MARTY edited this page Jan 9, 2019 · 15 revisions

This a place to collaborate on Queue Server API for mfbus

mfbus module contains a "queue server".

With this service, you can push and pull queues through a REST api. It's not a storage service because all objects have a lifetime and could be automatically cleaned.

Concepts

namespace

A namespace is just a kind of bucket for yours queues. It's a plain string (length < 64 characters). Allowed characters are alphanumeric ones [0-9a-zA-Z], . (dot), _ (underscore) and '-' (hyphen).

queue

A queue is just a queue name for your elements. It's a plain string (length < 64 characters). Allowed characters are alphanumeric ones [0-9a-zA-Z], . (dot), _ (underscore) and '-' (hyphen).

element

You can see element as a little (< 100 KB) binary file. It can be a text file, an image, a JSON or anything else. The service does not make any assumptions about the content of your elements. They are never altered.

lifetime

All elements have a lifetime (in seconds). The lifetime can be specific to each element even there is a default and a maximum value in global configuration.

API

POST /queue_server/{namespace}/elements/{queue}

This service push a new element at the end of given queue in the given namespace. The element is the (raw) body of your POST request.

Note: namespace and queue are created automatically.

If the operation is successful, the service will respond with a HTTP/202 Accepted status code.

You can also set:

  • a specific lifetime for your blob by adding (for example) a X-QueueServer-Lifetime: 60 header to your request
  • a specific indicative Content-Type for your blob by adding (for example) a X-QueueServer-ContentType: image/png header

GET /queue_server/{namespace}/elements/{queue}[?timeout=60]

This service pulls an existing element at the head of the given queue in the given namespace. The element is the (raw) body of the POST request used to add it.

The element is served with the Content-Type header you set during the POST request.

If the queue is empty:

  • if timeout=0 (default), the service reply with HTTP/204 No Content
  • if timeout>0, the service blocks until an element is available on the queue HTTP/200 OK or until the timeout HTTP/204 No Content

HEAD /queue_server/{namespace}/elements/{queue}

This service returns statistics about this queue (number of elements...)

HEAD /queue_server/{namespace}

This service returns statistics about the namespace (list of queues ?)

Clone this wiki locally