clusterroute

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package clusterroute holds the one cluster owner-forwarding wrapper every API surface shares. Each facade used to carry its own near-identical copy (plan D2): the copies disagreed on the lookup-error status (v1 500, the facades 503) and on whether to check the forwarding-loop header, and only Daytona resolved a per-owner name. One wrapper ends the drift; a facade supplies only its own error envelope and, when its routes are keyed by something other than "id", the key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(svc *service.Service, opts Options, local http.Handler) http.Handler

Wrap routes a per-sandbox request to the node that owns the sandbox, serving it locally when this node owns it (or when there is no cluster). It is the single owner-forward path for v1 and every facade. A nil svc (daemon started without one) serves locally.

func WrapSnapshot

func WrapSnapshot(svc *service.Service, name func(*http.Request) string, write ErrorWriter, local http.Handler) http.Handler

WrapSnapshot routes a snapshot-by-id request to the node that holds the snapshot's image, serving it locally when this node holds it, there is no cluster, or no home entry is registered. A snapshot lives in per-node SQLite with no node column, so — unlike Wrap, which forwards by the sandbox owner — this forwards by the replicated snapshot name → node index (a snapshot outlives its source sandbox, so OwnerOf cannot answer for it).

Each facade's snapshot id shape differs (Daytona's is the name; E2B's is a derived id), so the caller supplies a name resolver that maps its request to the snapshot's canonical name without a local store read. A resolver that returns "" (an id this node cannot map, e.g. a custom alias whose row is not local) falls through to local serving — the pre-index behaviour, no regression.

Types

type ErrorWriter

type ErrorWriter func(w http.ResponseWriter, status int, message string)

ErrorWriter renders one error in the calling facade's envelope.

type Options

type Options struct {
	// PathKey is the request path value holding the sandbox id. "" means "id".
	PathKey string
	// ResolveName also looks the key up as a per-owner sandbox name when it
	// is not a known id (Daytona's idOrName routes). Names are unique per
	// owner, resolved in the caller's namespace.
	ResolveName bool
	// ID overrides where the sandbox id comes from. Default: the PathKey
	// path value. /e2b/runtime carries it in a header, so it sets this.
	ID func(*http.Request) string
	// WriteError renders an error in the facade's envelope. Required.
	WriteError ErrorWriter
}

Options configures Wrap for one facade.

Jump to

Keyboard shortcuts

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