Documentation
¶
Overview ¶
Package cloudflare runs Tacklr sessions on Cloudflare Workers: each session is a SQLite-backed Durable Object that runs a durableobject.Object, and the Worker serves the host's own routes over a session.Client of those objects.
The Go program is compiled with GOOS=js GOARCH=wasm and calls Serve from main. shim.js, in this directory, is the JavaScript half: it starts the program once per isolate, defines the Durable Object class, and keeps each object's storage in one SQLite table. One program serves every object of its isolate, so objects are routed by id (durableobject.Registry).
Objects reach each other over the object protocol (durableobject.Handler and durableobject.Remote) through Durable Object stubs, inside Cloudflare's network. A host's routes are the only way in from outside.
When the Worker's env names OTEL_EXPORTER_OTLP_ENDPOINT, the program sends its spans there (package telemetry/otlpjson), so a Worker's turn is part of its client's trace.
This package and a host's main package are the only Tacklr code with a build tag: everything they run is plain Go, tested on Linux.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
// Sessions is the env name of the session objects' Durable Object
// namespace (wrangler's durable_objects binding).
Sessions string
// Connections is the env name of the connection objects' namespace.
// Each WebSocket to the Worker gets its own connection object, which
// serves it with Server.
Connections string
// Config is what every session object of the isolate runs with. It is
// called once per isolate, on the first request.
Config func(Env) (durableobject.Config, error)
// Server is the protocol server (such as ACP) over a client of the
// session objects, with its network policy set. It is called once per
// isolate. The Worker serves its other routes with Server.HTTPMux.
Server func(Env, *durableobject.Client) (*server.Server, error)
// MaxIdleObjects bounds the idle objects the isolate keeps in memory
// (durableobject.NewRegistry; zero: 64).
MaxIdleObjects int
}
App is a host's Worker: its session objects, and the protocol server that its clients connect to.