Help us shape the future of Go! Take the 2026 Go Developer Survey

staticsite

package
v1.0.0-rc.12 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package staticsite is a static release as files a host serves as they are (design/subsystems/deploy-targets.md, "Bucket websites"): the site's files from its release image, plus the two files AppTown's file server would otherwise compute, and the witness that a public address serves exactly this publication. It knows no provider; a file-host driver uploads the set in its order and asks the witness.

Index

Constants

View Source
const MaxBytes = 200 << 20

MaxBytes bounds a published site: every release uploads all of it, and AppTown holds it in memory while it does. Larger sites keep their own server on a container target.

View Source
const Root = "/srv"

Root is where a self-serving static image keeps its site.

Variables

View Source
var (
	EnvKey      = strings.TrimPrefix("/_apptown/env.js", "/")
	ReleaseKey  = strings.TrimPrefix(appcontract.ReleasePath, "/")
	InstanceKey = "_apptown/instance"
)

EnvKey and ReleaseKey are the two files AppTown writes into every set. InstanceKey is reserved too: a bucket website's private mark naming the installation that made the bucket (s3bucket), never a site's file.

View Source
var ErrNotWitnessed = errors.New("the address does not answer this publication yet")

ErrNotWitnessed: the address did not answer this publication within the budget. It is not a failure: a host or its cache may still be catching up, and the attempt stays uncertain for a later look.

Functions

func Answer

func Answer(ctx context.Context, address string) (status int, body string, err error)

Answer is what address answers for its marker now, past caches.

func Gone

func Gone(ctx context.Context, address string, tries int, interval time.Duration) error

Gone asks address for its marker until the host answers that it serves nothing there (404): what take-down witnesses. Only that answer is absence. No answer, a server error or any other status is not evidence that the site stopped, so after the last try the withdrawal is unconfirmed, saying what answered.

func Identity

func Identity(release, imageDigest string, browser map[string]string) (string, error)

Identity is what a publication's marker answers: <part>@<revision>+<set>, where <set> names the image and the browser values together, so the same revision published with other values is another publication. It is computed before the marker is written.

func Witness

func Witness(ctx context.Context, address, identity string, tries int, interval time.Duration, logf func(string, ...any)) error

Witness asks address for its marker, tries times interval apart, until it answers exactly identity. Every request carries a fresh query and no-cache, so no cache answers for the host. Anything else after the last try is ErrNotWitnessed, saying what answered.

Types

type File

type File struct {
	Key         string
	Body        []byte
	ContentType string
	Pass        Pass
}

File is one object of a published set.

func (File) NoStore

func (f File) NoStore() bool

NoStore: entry files and AppTown's files are never cached, so a reload asks for the current page and values.

type Pass

type Pass int

Pass is when a file is uploaded: assets first, then the entry files (HTML and the browser values), then the marker, last of all.

const (
	Assets Pass = iota + 1
	Entries
	Marker
)

type Set

type Set struct {
	Files    []File
	Identity string
	Digest   string
}

Set is one publication: its files in upload order, its identity (what the marker answers) and a digest over every key and body.

func Publish

func Publish(files []oci.File, release, imageDigest string, browser map[string]string) (Set, error)

Publish is the set for a release: the site's files, the browser values as /_apptown/env.js and the identity as /_apptown/release, replacing any file of those names. release is <part>@<revision>.

func (Set) Keys

func (s Set) Keys() []string

Keys are the set's object keys, sorted.

Jump to

Keyboard shortcuts

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