cloudflare

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Rendered for js/wasm

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

func Serve

func Serve(app App)

Serve serves app to shim.js and blocks. Call it from main.

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.

type Env

type Env struct {
	// contains filtered or unexported fields
}

Env is the Worker's environment: its vars, secrets and bindings.

func (Env) String

func (e Env) String(name string) string

String is the var or secret name, or "" when there is none.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL