Cashier

Order placement

POST /place-order
  • Payload
{
  "coffees" : [
    { "product": "COFFEE", "count": 1 }
  ]
}
  • Response
{
  "orderId": "00000000-AAAA-AAAA-AAAA-000000000000",
  "orderPlaced": "2019-08-01T00:00:00.000Z",
  "orderSize": 1
}

Get an overview of orders

GET /order-history

This returns the entire history. When the API is called, the Cashier first tries to process open jobs before answering.

[
  {
    "orderId" : "00000000-FFFF-FFFF-FFFF-000000000000",
    "orderPlaced" : "2019-07-31T01:00:00.000Z",
    "orderSize": 2,
    "jobs":
      [
        {
          "jobId": "00000000-2222-2222-2222-000000000000",
          "product": "KAKAO",
          "machine": "http://localhost:1337",
          "jobStarted": "2019-07-31T01:00:01.000Z"
        },
        {
          "jobId": "00000000-1111-1111-1111-000000000000",
          "product": "KAKAO",
          "machine": "http://localhost:1337",
          "jobStarted": "2019-07-31T01:01:01.000Z"
        }
      ]
  },
  {
    "orderId": "00000000-AAAA-AAAA-AAAA-000000000000",
    "orderPlaced": "2019-08-01T00:00:00.000Z",
    "orderSize": 1,
    "jobs":
      [
        {
          "product": "COFFEE"
        }
      ]
  }
]

Get details on a specific order

GET /order-history/:orderId

This returns the data for the specified order. When the API is called, the Cashier first tries to process open jobs before answering.

{
  "orderId": "00000000-AAAA-AAAA-AAAA-000000000000",
  "orderPlaced": "2019-08-01T00:00:00.000Z",
  "orderSize": 1,
  "jobs":
    [
      {
        "product": "COFFEE"
      }
    ]
}

Get an overview of queued jobs

GET /queued-jobs

When the API is called, the Cashier first tries to process open jobs before answering.

{
  "count": Integer,
  "jobs": [
    {
      "product": "COFFEE",
      "orderId": "00000000-AAAA-AAAA-AAAA-000000000000",
      "orderPlaced": "2019-08-01T00:00:00.000Z",
      "orderSize": 1
    }
  ]
}

Make the Cashier process jobs

POST /process-jobs

Iterate over non-processed jobs and over all Coffee Machines to try and deploy them. On successful deployment, the jobStarted is updated.

  • Payload
{
}
  • Response
Code Content
200 {"message: "X jobs deployed, Y jobs still queued."}

Configuration

Provide URLs to the Coffee Machines.

  • Endpoint
POST /configure
  • Payload
{
  "coffeemachines" : ["http://localhost:1234", "http://localhost:5678"]
}

Prometheus metrics

GET /metrics
  • Response
# HELP cashier_queue_length The current queue length.
# TYPE cashier_queue_length gauge
cashier_queue_length 0