app

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: GPL-3.0 Imports: 193 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 PerfAllocEnv = "ETHER_PERF_ALLOC"

PerfAllocEnv enables process-wide allocation sampling for tagged traces. ReadMemStats stops the runtime briefly, so ordinary traces and the scale gate leave it off; etherperf enables it for its isolated measurements.

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 BuiltinSubtitleDescriptors added in v0.3.3

func BuiltinSubtitleDescriptors() []extend.Descriptor

BuiltinSubtitleDescriptors returns the built-in subtitle provider descriptors. Stremio subtitle add-ons are installed add-ons: each publishes its own descriptor (plugin:<id>/subtitles).

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) EventBus

func (a *App) EventBus() *events.Bus

EventBus returns the process-wide structured event bus.

func (*App) EventRegistry

func (a *App) EventRegistry() *events.Registry

EventRegistry returns the schema registry backing EventBus.

func (*App) FlowsActions

func (a *App) FlowsActions() flows.ActionRegistry

FlowsActions returns the live Flows action registry so built-in actions (F3) and plugins can register action handlers dynamically.

func (*App) FlowsEngine

func (a *App) FlowsEngine() *flows.Engine

FlowsEngine returns the Flows execution engine.

func (*App) FlowsStore

func (a *App) FlowsStore() *flows.SQLStore

FlowsStore returns the durable Flows SQL 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 {
	// BreakEvidenceObserver is an opt-in local owner diagnostic hook. It runs
	// synchronously while the analyzed source lease is open; never retain its URL.
	BreakEvidenceObserver func(context.Context, markers.BreakInput, markers.BreakEvidence)

	// 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
	// LogLevel controls the process handler, including existing child loggers.
	LogLevel *slog.LevelVar
	// 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
	// FlowActions optionally injects a Flows action registry; nil creates an
	// empty registry ready for dynamic built-in and plugin action registration.
	FlowActions flows.ActionRegistry
	// 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"`
	AllocBytes uint64                `json:"allocBytes,omitempty"`
	Allocs     uint64                `json:"allocs,omitempty"`
	Statements []store.StatementStat `json:"statements,omitempty"`
}

PerfTraceRecord is one line of the ETHER_PERF_TRACE file.

type PluginLiveService

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

PluginLiveService mediates plugin library live-tab listings, uncached stream resolution, viewer/library access checks, and opaque thumbnail registration.

func NewPluginLiveService

func NewPluginLiveService(app *App) *PluginLiveService

NewPluginLiveService builds a bounded live-tab coordinator bound to app.

func (*PluginLiveService) AllowViewer

func (s *PluginLiveService) AllowViewer(ctx context.Context, viewer *core.Viewer, libID core.LibraryID, tab string) (core.Library, string, error)

AllowViewer checks current viewer state, library visibility, active plugin state, protocol publication (from core.LiveApp(ctx)), and visible live tab.

func (*PluginLiveService) HasVisibleLiveTab

func (s *PluginLiveService) HasVisibleLiveTab(ctx context.Context, lib core.Library, tabKey string) (string, bool)

HasVisibleLiveTab reports whether lib declares a visible "live" tab (matching tabKey when non-empty) and returns the resolved tab key.

func (*PluginLiveService) List

List queries a plugin library's live endpoint with a brief bounded TTL cache.

func (*PluginLiveService) RegisterThumb

func (s *PluginLiveService) RegisterThumb(libID core.LibraryID, rawURL string) (ref string, hash string)

RegisterThumb maps a plugin-provided live thumbnail URL to an opaque, library-scoped image reference ("library-live/<32-hex>") so raw upstream URLs never cross into Vela or console responses.

func (*PluginLiveService) Resolve

Resolve resolves one live item to its fresh upstream stream URL. Never cached.

func (*PluginLiveService) ResolveThumb

func (s *PluginLiveService) ResolveThumb(libID core.LibraryID, hashOrRef string) (string, error)

ResolveThumb resolves a library-scoped thumb hash or "library-live/<hash>" path back to its registered upstream URL.

Source Files

Jump to

Keyboard shortcuts

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