drift Docs
Pages
drift Docs
Start
What is Drift?
The tour, if you are new here.
Use cases
Whether Drift does your thing.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, four unit prices, two rules.
Moving off Azure
Estimate, snapshot and transform a resource group.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Route gates, API keys and your account.
Teams
More than one person on one account.
Security
Boundaries, sandboxing and hardening.
Troubleshooting
Error codes
What went wrong, and what to do about it.
Legal
Acceptable use
What a slice may not be used for.
Data processing
The DPA, and every sub-processor.

Backbone Queues

FIFO message queues. A queue springs into existence the first time you push to it, no separate declaration required. Push from anywhere; process messages with a queue-triggered function:

Go
drift.Backbone.Queue("orders").Push(map[string]any{"item": "widget", "qty": 3})

A message body must be a JSON object. A bare string, number or array is rejected with 400 queue and body required. Queue names take alphanumerics plus ., _ and -, first character alphanumeric, up to 255 bytes. A push past the queue's depth answers 429.

The depth is the depth of the queue's block in the Driftfile; a queue whose block leaves it out, or that has no block, takes the slice's limits.queue_depth.

Driftfile
slice "shop" {
  limits {
    queue_depth = 500
  }
}

backbone {
  queue "orders" {
    depth = 1000
  }

  queue "emails" {}
}

Here orders holds 1000 messages and emails holds the slice's 500. A queue the file stops naming is removed with its messages, so the plan lists it as a removal and as a possible data loss, and drift apply asks about each.

Shell
drift backbone queue push orders '{"item":"widget","qty":3}'
drift backbone queue peek orders     # look without removing
drift backbone queue pop  orders     # take the next message
drift backbone queue len  orders
drift backbone queue drop orders     # delete the queue and every message in it

Queue-triggered functions

Declaring a function "QUEUE orders" in the Driftfile binds it to that queue; see Atomic triggers. A background poller pops the queue every 500 ms and invokes the function once per message.

The function receives the message's inner body object, not the {id, body, timestamp} envelope that queue peek and queue pop return. Read your own fields straight off the payload.

Retries and the dead-letter queue

An invocation that fails puts the message back with a _drift_retries counter. After three attempts the message moves to a queue named <queue>-dlq, created on the first dead letter. It is an ordinary queue, so inspect and drain it like any other:

Shell
drift backbone queue len  orders-dlq
drift backbone queue peek orders-dlq
drift backbone queue pop  orders-dlq