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

app

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: GPL-3.0 Imports: 129 Imported by: 0

Documentation

Overview

Package app wires Ether's components into one running server: the Plex front end and the owner UI on one port, and the background services (catalogue sync, plex.tv registration, prefetch, LAN discovery) behind it.

Index

Constants

View Source
const PerfTagHeader = "X-Ether-Perf-Tag"

PerfTagHeader is copied into the trace record of the request carrying it.

View Source
const PerfTraceDepthEnv = "ETHER_PERF_TRACE_DEPTH"

PerfTraceDepthEnv sets how many callers each traced statement's site records (default 1).

View Source
const PerfTraceEnv = "ETHER_PERF_TRACE"

PerfTraceEnv names a file that receives one JSON line per HTTP request (surface, path, status, duration and its database work). cmd/etherperf sets it; production leaves it unset.

View Source
const PprofAddrEnv = "ETHER_PPROF_ADDR"

PprofAddrEnv enables Go's profiler on a loopback address, for profiling a hot path on real data (cmd/etherperf sets it). Non-loopback addresses are refused: profiles expose memory contents.

Variables

View Source
var ErrUnresponsive = errors.New("app: server unresponsive to local health probes")

ErrUnresponsive is returned by App.Run when the server stopped answering its own local health probe. The process then exits non-zero so the service manager restarts it.

Functions

func Serve added in v0.2.4

func Serve(ctx context.Context, opts Options) error

Serve owns the complete application lifetime. It binds the port as soon as the data directory is locked, so the console can show a starting server's progress (startup.Gate), and keeps it across App instances. A UI cluster transition first stops HTTP and every background writer and closes SQLite, then migrates and starts a fresh App. A start that fails after the port is bound does not exit (a service manager would only restart it into the same failure): the status page explains the failure, offers a restore on a standalone server, and the start is retried with backoff. It works in the foreground and under every OS supervisor.

Types

type App

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

App is a running Ether server.

func New

func New(ctx context.Context, opts Options) (_ *App, err error)

New builds every component. Nothing listens until Run.

func (*App) Close

func (a *App) Close()

Close releases every component in reverse order of construction.

func (*App) Config

func (a *App) Config() *config.Store

Config is the settings store.

func (*App) Handler

func (a *App) Handler() http.Handler

Handler is the combined Plex + owner UI handler (tests).

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run serves until ctx is cancelled.

func (*App) WatchNotifications added in v0.2.4

func (a *App) WatchNotifications(executable string) (func(bool) error, error)

WatchNotifications is enabled by the executable, never by embedded/test apps.

type Options

type Options struct {

	// NotificationExecutable enables the independent crash watcher for executable runs.
	NotificationExecutable string
	DataDir                string
	Version                string
	// Logger receives everything; the admin log ring is teed onto it.
	Logger *slog.Logger
	// Spike forces spike mode (local files, no Usenet) on top of config.
	Spike bool
	// SpikeFiles are extra local files for spike mode.
	SpikeFiles []string
	// DBRetryMin / DBRetryMax bound the backoff while a clustered node
	// waits at startup for an unreachable PostgreSQL server (1s / 30s).
	DBRetryMin, DBRetryMax time.Duration
	// FixtureMedia, when set, is the resolver indexer, release health checker,
	// and playback engine. Production leaves it nil.
	FixtureMedia interface {
		core.Indexer
		core.HealthChecker
		core.Engine
	}
	// FixtureTranscoder, when set, replaces the ffmpeg manager so every
	// protocol shares one transcode budget without an encoder binary.
	FixtureTranscoder core.Transcoder
	// CatalogNow, when set, is the catalog clock from construction. Tests
	// pin it so a minute snapshot cannot expire while a background browse runs.
	CatalogNow func() time.Time
	// contains filtered or unexported fields
}

Options configure a run.

type PerfTraceRecord added in v0.3.0

type PerfTraceRecord struct {
	// Tag echoes the X-Ether-Perf-Tag request header, so the harness can
	// join a trace line to the step that sent it.
	Tag        string                `json:"tag,omitempty"`
	Surface    string                `json:"surface"`
	Method     string                `json:"method"`
	Path       string                `json:"path"`
	Status     int                   `json:"status"`
	Bytes      int                   `json:"bytes"`
	Start      time.Time             `json:"start"`
	Duration   time.Duration         `json:"duration"`
	Queries    int64                 `json:"queries"`
	Writes     int64                 `json:"writes"`
	Rows       int64                 `json:"rows"`
	DBTime     time.Duration         `json:"dbTime"`
	LockWait   time.Duration         `json:"lockWait"`
	Statements []store.StatementStat `json:"statements,omitempty"`
}

PerfTraceRecord is one line of the ETHER_PERF_TRACE file.

Source Files

Jump to

Keyboard shortcuts

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