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.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Accounts, tokens and scopes.
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.

Triggers

An HTTP route is one way to reach a function. A queue and a schedule are the other two, and neither needs a caller: the slice invokes the function on your behalf.

Queue-triggered functions

A function doesn't have to be called over HTTP. Give it method: queue and name the queue as its route and the slice polls a Backbone queue on your behalf:

Driftfile
atomic:
  functions:
    - route: orders
      method: queue
      handler: handle_order
Python
def handle_order(body, req):
    # body is the message that was pushed onto the "orders" queue
    drift.backbone.nosql.collection("orders").insert(body)
    return 200, "OK", {"stored": True}

A queue handler takes the body shape, (body, req), and the popped message is the body. It returns the same three (or four, in Go) values an HTTP handler does.

Behaviour Value
Poll interval500 ms
Retries3. A failed message is requeued with its retry count; once exhausted it moves to <queue>-dlq.
What counts as a failureThe invocation errored, or the handler returned a 5xx status.
ReachabilityRegistered under a synthetic queue method that no HTTP request can match, so a queue handler has no URL.
BookingThe slice books it under the name you declared — queue:orders — exactly like an HTTP function.

None of those defaults are configurable. Since any HTTP function has a public URL, a post:… function is your webhook receiver. Point Stripe, GitHub or your provider straight at it.

Scheduled functions

A schedule is not an identity — it is something a function also does. Give any function a cron: and it runs on that schedule in addition to its own trigger. Same code, two ways in:

Driftfile
atomic:
  functions:
    - route: nightly-rollup
      method: post
      handler: PostNightlyRollup
      cron: "0 2 * * *"        # 02:00 daily, and still callable over HTTP
    - route: hourly-cleanup
      method: post
      handler: PostHourlyCleanup
      cron: "0 * * * *"

Standard 5-field POSIX cron: minute hour day-of-month month day-of-week. Seconds and the 6-field quartz format are not supported. The schedule registers as part of the deploy, with no post-deploy step, and the deploy is refused if it would push the slice past its scheduled-job allowance.

Each fire delivers a small JSON body, so a scheduled handler takes the body shape:

JSON
{ "fired_at": "<RFC 3339 timestamp>", "schedule": "0 2 * * *" }

Anything else the handler needs comes from secrets or Backbone.