static

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MPL-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package static serves bundled / workspace files for the txco://static op, layered first-match-wins: a routed stack's own <workspace>/OPS/<stack>/FILES/** , the chassis-wide <workspace>/FILES/** , then the embedded chassis default (favicon.ico).

The set + the bytes are loaded into memory at startup and rebuilt on dbcache reload (see Index). A request NEVER touches the filesystem: Resolve is a pure in-memory radix lookup, so static serving and the boot pipeline that calls it stay off the disk critical path.

Index

Constants

View Source
const (
	MaxIndexFiles = 2048
	MaxIndexBytes = 64 << 20
	MaxIndexDepth = 10
)

Index-build budget across the workspace layers (the embedded default is trusted and always loaded, exempt from these). Bounds the in-memory cache so a runaway FILES/ tree can't exhaust RAM; overflow is logged and skipped (already-indexed files still serve).

View Source
const MaxFileBytes = 1 << 20

MaxFileBytes caps any single static file. Same 1 MiB ceiling the continuation worker callback uses (server/personality/web/continuation.go). Larger files are skipped at index-build time (never read per request).

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

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

Index is the in-memory static set, three layers deep (per routed stack → chassis-wide → embedded). Trees are immutable (github.com/hashicorp/go-immutable-radix); Rebuild builds fresh ones and swaps under mu. Reads snapshot the pointers under mu then use the immutable structures lock-free — the processor.Unit.Mux idiom.

func NewIndex

func NewIndex(root string, log *zap.Logger) *Index

NewIndex builds the index immediately so the chassis serves correctly before the first reload.

func (*Index) Lookup

func (ix *Index) Lookup(stack, reqPath string) Result

Lookup resolves a request, layered first-match-wins for an exact file, and otherwise reports whether the path is under a static-owned directory prefix. Pure in-memory; no filesystem access.

func (*Index) Rebuild

func (ix *Index) Rebuild()

Rebuild reloads every layer from disk + embed into fresh structures and atomically swaps them in. Called at startup and on dbcache reload — never on the request path.

type Result

type Result struct {
	Found bool
	Owned bool
	Body  []byte
	Ctype string
	ETag  string
}

Result is the outcome of a Lookup.

Found      → an exact file; serve Body (200) or 304 on ETag match.
!Found && Owned → request is under a static-owned directory prefix;
                  the op must answer 404 (NOT fall through).
!Found && !Owned → not static's; the op returns "{}" (keep routing).

Jump to

Keyboard shortcuts

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