Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.33 KB

File metadata and controls

55 lines (40 loc) · 1.33 KB

Worker Queue

⚠️⚠️ It's just a PoC made in a few hours, there is a lot of optimizations to be done and refactoring to be really usable ⚠️⚠️

Basic use

  1. Generate an authorization basic token following the authorization guide
  2. Add some element in the queue using the put endpoint
  3. Get the queue elements with get endpoint

Setup

There are some configurations to be done in the worker:

Environment variables

  • TTL - Time to the element in the queue live
  • PASSWORD - Global user password

Worker KV

A Worker KV labeled as QUEUE.

Authorization

Authorization is made through the basic authorization method, where the user can be any username and the password is the PASSSWORD enviroment variable.

Endpoints

Get next element

Endpoint: /queue/{queue name}

HTTP method: GET

Headers:

  • Authorization: Basic authorization token

Response:

{
  "index": "202110302133649351abaa14edfb4b72a54ca8ac305047ea",
  "data": "Test"
}

Push an element

Endpoint: /queue/{queue name}

HTTP method: PUT

Headers:

  • Authorization: Basic authorization token

Body: Any data JSON encoded

Response:

{
  "status": "ok"
}