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.

Queues

drift.Backbone.Queue(name): FIFO message queues.

Signatures

Go
// Pop takes the next message destructively; Peek reads the head and leaves it
Push(body any) (string, error)   // returns the id the slice gave the message
Pop() (json.RawMessage, error)   // the body; (nil, nil) when the queue is empty
Peek() (json.RawMessage, error)  // the body, left in the queue
Len() (int, error)               // how many messages are waiting

All six SDKs carry the four calls: push, pop, peek and len in Python, Node.js, Ruby and PHP (await them in Node.js). Rust's push returns Option<String> and pop returns Option<Value>, which fold a refusal into None; try_push and try_pop return a Result that says why, peek and len return a Result, and is_empty is len compared with zero.

A message body must be a JSON object. A bare string, number or array is rejected with 400 queue and body required, and a push past the queue's depth answers 429. The depth is the depth of the queue's block in the Driftfile (queue "orders" { depth = 500 }), or the slice's queue_depth limit when the block leaves it out.

Push-based or pull-based, not both

Pop is the pull consumer, for a function that drains a queue on its own schedule. The push path is a function the Driftfile declares as function "QUEUE orders", which the platform invokes once per message. Use one or the other on a given queue.

A worker receives the inner body, not the envelope.

A queue-triggered function is handed the payload, not the {id, body, timestamp} envelope that Pop and the CLI's peek return. Read your own fields straight off the payload.

On a deployed slice, a queue exists only once something has pushed to it.

Pop on a name nothing has ever pushed to answers 404, which every SDK surfaces as an error. Pop on a queue that has held a message before, even if it is empty now, answers cleanly with nothing, no error at all. Locally there is no such distinction: every empty Pop is quiet regardless of whether the name has been used before. Push once, or otherwise be ready for that first error, before a worker's very first Pop on a fresh deploy. drift apply does that push for every queue block the Driftfile declares (it pushes a setup message and pops it again), so the first-Pop error is for a name the file does not declare.

A failed invocation is requeued with a retry counter; after three attempts the message moves to <queue>-dlq, an ordinary queue you can drain like any other. The Atomic guide has the poll interval and what counts as a failure.