Expand description
The compute sql-shim (PLAN-compute-bindings, Phase 0).
An opaque compute workload (container / micro-VM) cannot import the WASI sql
host interface a handler uses. This shim gives it the same per-tenant-scoped
SqlBackend over a wire protocol: a single per-node HTTP endpoint speaking
libsql’s hrana-over-HTTP /v2/pipeline JSON, so an off-the-shelf libsql
client in the guest connects with zero boatramp-specific code.
§Isolation
Requests authenticate with Authorization: Bearer <token>; the token maps to an
Arc<dyn SqlBackend> already resolved for exactly one project/site (via the
same SqlBackends::database call a handler makes). The wire protocol has no
“open database” verb — a request can only run statements against the backend its
token was registered with — so a workload is structurally incapable of naming
another tenant’s data, exactly like the WASI handler. The token is boatramp-minted
and instance-scoped; the operator’s DB credentials never enter the guest.
Structs§
- SqlShim
- The shim’s token → resolved backend registry, shared with the HTTP handler.
- SqlShim
Resolver - Resolves a workload’s
sqlComputeBindings to a shim endpoint + credential injected into the guest env. Holds the sameSqlBackendsprovider a handler uses, the shim registry, the guest-reachable shim base URL, and a per-node secret used to derive a token that is deterministic (recomputable at release / re-register without persisting it) yet unguessable (keyed by the secret).
Functions§
- spawn_
sql_ shim - Activate the compute sql-shim: bind its listener and build the resolver to hand
the compute reconcile.
shim_urlis the guest-reachable base URL (e.g.http://10.0.0.1:8081, or the docker bridge gateway); the shim binds0.0.0.0:<port-from-url>. ReturnsNone— the feature stays off — when there is no sql provider, noshim_url, or the bind fails.