emq

command module
v0.0.0-...-0dc6217 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2020 License: MIT Imports: 12 Imported by: 0

README

emq

Tiny message queue server over HTTP. Primarily an excuse for me to learn net/http.

Features:

  • Retries
  • Per-dispatch timeouts
  • Job timeouts

Running

$ go install github.com/eugene-eeo/emq
$ emq --addr ':8080'

Endpoints

POST /enqueue/<queue-name>

Enqueues a task in the specified queue-name. The POST request should include a JSON object in the body with the following schema:

{
    "content": { /* Anything can go here */ },
    "retry":  1, // job duration in seconds (default: 5 minutes)
    "expiry": 1  // expiry in seconds (default: 1 day)
}
  • retry determines how long after a task has been dispatched to a worker it should be considered a failure if the task hasn't been ACKed in that amount of time.

  • The expiry key determines how long the task should live in the queue before it is deleted, regardless of whether it has been dispatched.

POST /wait/

The trailing slash is important. Waits for queues to be ready and dequeues tasks from them. The POST request should contain a JSON object with the following schema:

{
    "timeout": 1, // timeout in milliseconds (default: 0)
    "queues": ["queue-name-1", "queue-name-2"]
}
  • The queues array can contain repeats.
  • By default timeout's value will be 0, which is the fast case where the waiter returns almost immediately.

The reply will be an array of tasks, as follows:

[
  {
    "id": "job-id",
    "content": { /* job-content */},
  },
  ...
]

It may contain nulls where queues are not ready (have no tasks). By definition, nulls will only appear when the waiter has timed out or a timeout of 0 was specified.

POST /ack/

Mark tasks as completed. Also deletes it from the queue.

{
    "ids": ["..."]
}
POST /nak/

Same as /ack, but mark tasks as failed. Failed tasks may be retried many times before they expire. However they will be put in the back of their queues.

GET /peek/<queue-name>?n=<num>

Get (but not dispatch) at most num number of jobs from <queue-name>.

GET /queues/

Get the names of all current queues (as a JSON array of strings).

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package uid implements simple 16-byte UIDs.
Package uid implements simple 16-byte UIDs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL