Skip to content

Running locally ​

Last updated 

The spoolersh/memspoolerd image serves the same HTTP API as the hosted service, with ephemeral in-memory storage. It needs no account and issues no API key. Nothing persists: every message is lost when the container exits. It is free to run for your own purposes, in development, in tests and in production; it may not be provided to others or hosted as a service. See the memspoolerd License.

Run it ​

sh
docker run --rm -p 127.0.0.1:8080:8080 spoolersh/memspoolerd

The port is bound to loopback on purpose: every bearer value authenticates here, so anything that can reach the port can use it. --rm discards the container on exit – there is nothing in it worth keeping.

Point the quickstart's two variables at it:

sh
export SPOOLER_API=http://127.0.0.1:8080/v1
export SPOOLER_KEY=local

The key value is not checked: this server holds one implicit account, and any bearer token identifies it. The header is still required – a request without one fails 401. Every operation in the API reference is available, with the same request shapes and response formats; the environment-specific statuses that never occur here are listed below. The startup banner names the address it serves and the limits in force.

Declaring queues ​

A restarted container starts empty, queues included. A client that created its queues once, at its own start, and outlived the container fails 404queue_not_found on every request from then on. Creating the queue again on each queue_not_found is the other way out, and it spreads recovery code over every call path for a condition the hosted service never produces. Declare the queues to the container instead: they exist on every start. Mount a directory at /etc/spooler/queues.d:

sh
docker run --rm -p 127.0.0.1:8080:8080 \
  -v ./queues.d:/etc/spooler/queues.d:ro spoolersh/memspoolerd

Each *.yaml file in it declares a queue. An empty file declares one named after the file, with default settings; the settings are the fields of Create a queue, and name overrides the file name:

yaml
# queues.d/orders.yaml
name: orders:eu
dedupWindowSeconds: 300

A file may hold several queues separated by ---, each with a name. The queues are created before the server starts listening, so a container that is healthy has them. A file that cannot be read, a name declared twice, or a setting the API would refuse stops the server at startup with the file named in the error. Other files in the directory are ignored. The directory is read once; restart to apply a change. In Compose, the files can be inlined:

yaml
services:
  spooler:
    image: spoolersh/memspoolerd
    ports:
      - "127.0.0.1:8080:8080"
    configs:
      - source: orders
        target: /etc/spooler/queues.d/orders.yaml

configs:
  orders:
    content: |
      dedupWindowSeconds: 300

What differs from the hosted service ​

  • Nothing persists. The spool holds one copy of your data in memory. A restarted container starts empty; declared queues are created again on every start; their messages are not.
  • One spool. Only default exists; any other name fails 404, as it would on the hosted service.
  • Limits are not plan limits. Fixed limits apply here, printed at startup, and stored data is bounded by its memory budget. The hosted service's limits are per plan – see limits.
  • Rate limiting is off. 429 never occurs.
  • Every key authenticates. 401 occurs only for a missing or non-bearer Authorization header, and 402 never occurs.
  • The spool is always available. 503 never occurs, and no primary changes, so no lease is dropped by a failover – see Delivery.

A client that has run only against this image has not exercised its handling of 402, 429, 503, or a 401 for a rejected key. Those responses are in errors.

In continuous integration ​

Run one container per test run and let it go: there is no state to reset beforehand and nothing to clean up after. Pin a version tag so the selected image cannot change between test runs. The image declares a health check, so a runner that waits for the container to become healthy will not race the first request; without one, poll List queues until it answers 200.