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.

Streaming

stream = "sse" and stream = "ws" on a function mark a function as streaming:

Driftfile
slice "feed" {}

atomic {
  backend "default" {
    function "GET /events" {
      handler = "GetEvents"
      memory  = "32MiB"
      stream  = "sse"
    }

    function "GET /socket" {
      handler = "GetSocket"
      memory  = "32MiB"
      stream  = "ws"
    }
  }
}

The slice then hijacks the connection rather than buffering a single response: for SSE it writes the text/event-stream headers and relays your process's stdout line by line; for WebSocket it completes the handshake and bridges client frames to stdin and stdout lines back to the client.

Every SDK carries the matching entry points (drift.RunSSE / drift.run_sse / drift.runSSE and the WebSocket equivalents), which read the request envelope from stdin and write frames to stdout.

The deploy path does not wire them up.

drift apply generates the program's entry point itself, and the generated one calls your handler through the ordinary request/response wrapper. It never calls run_sse or run_ws, and for Go it replaces any main.go you ship. A deployed function with stream = "sse" therefore emits one JSON envelope, not an event stream. Streaming is reachable from a hand-built entry point, not from drift apply.

Both streaming paths carry the same per-invocation runtime budget as an ordinary call: a watchdog kills the process when the budget is spent, and the stream ends.

To fan one message out to many clients instead of streaming a single call's response, use Backbone's Realtime channels.