drift Docs
Start
What is Drift?
The tour, if you are new here.
Why Drift?
The case for a smaller cloud.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, five 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.

Locks

drift.Backbone.Lock: distributed locks, so work is not done twice.

Signatures

Go
// Acquire returns a token you pass back to Release
Acquire(name string, ttlSeconds int) (string, error)   ·   Release(name, token string) error
Go
token, err := drift.Backbone.Lock.Acquire("payout:42", 30)   // hold for up to 30s
if err == nil {
    defer drift.Backbone.Lock.Release("payout:42", token)
    // ... do the work exactly once ...
}

Size the TTL for the whole job

There is no renew from a function.

Every SDK Acquire mints a fresh token, so a function cannot extend a lock it already holds. Pick a TTL that covers the work. The CLI names the owner itself, which is what lets drift backbone lock renew exist there and not here.

A lock held by someone else answers 409, so the second worker backs off. Past your tier's concurrent-lock limit, Acquire answers 429. A TTL of zero or less becomes 30 seconds. Lock names are not charset-restricted, so payout:42 is fine.

Locks are not captured in a snapshot, so restoring one gives you no held locks, which is the correct outcome for a primitive whose whole meaning is "right now".