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

serverapp

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package serverapp composes stored-data application services and transports. Local lifecycle and remote authentication live outside this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FailureSummary added in v0.2.1

func FailureSummary(failures []CollectionFailure) string

FailureSummary joins failures for a single diagnostic.

func Handler

func Handler(ctx context.Context, service *contextservice.Service, store reviewservice.MutationStore, assets fs.FS, defaultID string, options ...Options) http.Handler
func PageNavigation(r *http.Request) bool

PageNavigation reports a safe top-level document navigation, such as opening an emailed or shared link. Browsers send these cross-site with SameSite=Lax cookies; callers admit them only for page routes, never APIs.

func Run

func Run(ctx context.Context, endpoints []Endpoint, tasks []Task, ready func()) error

Run ties HTTP listeners and background work to one foreground lifetime. All tasks must honor cancellation before returning; storage closes afterwards.

func SameOrigin

func SameOrigin(r *http.Request) bool

SameOrigin accepts HTTP and HTTPS deployments, including TLS termination.

Types

type Capabilities

type Capabilities struct {
	IngestionEnabled bool
	QueuedIngestion  bool
	Collection       bool
	// Selection is the collected checkouts' scope; empty without collection.
	Selection Selection
}

Capabilities are resolved once by the transport composition. Both admission paths accept ingestion.Request; local collection calls the service directly.

func (Capabilities) Input added in v0.2.1

func (capabilities Capabilities) Input() string

Input names what a local process serves: its selected checkout or the discovered checkouts, which it can collect again, or one fixed capture (piped stdin or a fixture) with nothing to switch to. Only checkout processes own collections.

type Collect added in v0.2.1

type Collect func(context.Context, func(ingestion.Request) error) ([]CollectionFailure, error)

Collect publishes completed checkout requests serially before returning the remaining checkout failures. It joins its workers before returning, including after cancellation or a publication error.

type Collection added in v0.2.1

type Collection struct {
	Requests []ingestion.Request
	Failures []CollectionFailure
}

Collection is one user-requested collection of the composition's selected checkouts. Failures name checkouts that could not be collected.

type CollectionFailure added in v0.2.1

type CollectionFailure struct {
	Path         string `json:"path"`
	Detail       string `json:"detail"`
	Code         string `json:"code,omitempty"`
	DiagnosticID string `json:"diagnosticId,omitempty"`
}

type Collections added in v0.2.1

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

Collections serializes checkout collection and publication. The first UI load request joins startup, including when startup finished before the browser opened. Later requests collect fresh snapshots. A disconnected browser does not cancel startup, whose lifetime belongs to the foreground process.

func NewCollections added in v0.2.1

func NewCollections(service *contextservice.Service, selection Selection, collect Collect, defaultID string) *Collections

func (*Collections) Initial added in v0.2.1

func (handler *Collections) Initial(completed func(Published, error)) Task

Initial reserves the startup result before serving requests and returns the task that collects it. Call once, before Run. Collection errors are reported to the UI and callback; the server stays available for retry.

func (*Collections) ServeHTTP added in v0.2.1

func (handler *Collections) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Endpoint

type Endpoint struct {
	Server   *http.Server
	Listener net.Listener
}

type Options

type Options struct {
	Queue ingestionqueue.Queue
	// Collections coordinates local startup and explicit checkout collection.
	// Piped captures, fixtures and remote storage have none.
	Collections *Collections
}

func (Options) Capabilities

func (options Options) Capabilities() Capabilities

type Published added in v0.2.1

type Published struct {
	Publications []contextservice.Publication
	Failures     []CollectionFailure
	// contains filtered or unexported fields
}

Published is the outcome of ingesting one collection.

func Publish added in v0.2.1

func Publish(ctx context.Context, service *contextservice.Service, collection Collection) (Published, error)

Publish selects each collected checkout into the composition's scope, then ingests it serially. Each observation commits atomically on its own; a rejected request is reported with its checkout and never blocks the others.

func (Published) Newest added in v0.2.1

func (published Published) Newest() (contextservice.Publication, bool)

Newest prefers current contexts with changes, then current clean contexts. Among equals, the checkout containing the collection's input path wins, so `diffx PATH` inside a worktree opens that worktree; then recent activity. A successful collection of older observations still has an available default.

type Selection added in v0.2.2

type Selection string

Selection names which checkouts a local process collects.

const (
	// SelectedCheckout collects only the checkout the process was started for.
	SelectedCheckout Selection = "checkout"
	// DiscoveredCheckouts collects every checkout discovered under the paths.
	DiscoveredCheckouts Selection = "checkouts"
)

type Task

type Task func(context.Context) error

func Prune

func Prune(prune func(time.Time) error) Task

Prune removes expired state hourly. A failed pass is logged and retried at the next tick; retention cleanup never stops serving.

Jump to

Keyboard shortcuts

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