Backends
A backend is a single-language backend, Drift's unit of a “service” (what you'd put in one container elsewhere), minus the container. One language, one dependency manifest (go.mod / requirements.txt / package.json / …), and as many functions as you like across flat files in one folder.
The common case is the simplest there is: drop your handlers straight into atomic/ as flat files, with no per-function folders. That flat set is a backend (the implicit default one), and a function belongs to it by being declared in backend "default" inside the atomic block:
-
atomic/one backend, one language, one backend
- auth.goPOST /signup · POST /login · GET /me
- groups.gocreate · list · join · get
- lib.goshared helpers, just a sibling file
- go.modone manifest for the whole backend
Need a second language? That's a second backend, a second service. Give each its own folder under atomic/ (say atomic/api/ in Go and atomic/ml/ in Python), each with its own manifest, and declare those functions inside a backend block named for the folder:
slice "shop" {}
atomic {
# Go, in ./atomic/api
backend "api" {
function "POST /signup" {
handler = "PostSignup"
memory = "32MiB"
}
}
# Python, in ./atomic/ml
backend "ml" {
function "POST /predict" {
handler = "post_predict"
memory = "128MiB"
}
}
}A backend named anything but "default" lives in ./atomic/<name>; dir on the backend points it at another folder.
Mixing languages within one backend is refused before anything builds; a second language is, by definition, a second backend. Backends integrate through Backbone (queues, NoSQL, locks), exactly the way microservices integrate through a broker, never by importing each other.
A backend is an authoring + dependency boundary, not a URL one: a route comes from the function's label ("POST /predict"), so the backend never appears in the path. It is also the scope a handler is looked up in, which is why two backends can each have a handle. Shared code (lib.go, crypto.go) is an ordinary file in the same package and never a copy. Go, Python, Node, Ruby and PHP build as multi-function backends; a Rust backend holds one function.