app

package
v0.0.0-...-95891f2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 115 Imported by: 0 modules, 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 app is the application bootstrap and dependency injection root. It creates and holds all shared infrastructure (DB pool, Redis client, Echo instance) and wires together all plugins, modules, and widgets.

Package app wires together all application dependencies.

This file holds one-time, idempotent startup backfills: data fix-ups that replay an addon's enable-effects for campaigns that enabled it before the effect existed. They run through the owning services, never hand-rolled SQL, so they stay safe to run on every boot.

Package app — export_adapters.go provides adapter implementations that bridge plugin services to the campaign export/import interfaces. Each adapter converts plugin-specific types to the export model types defined in campaigns/export.go.

Package app — export_adapters_tables.go carries rolling tables, quest sheets and crafting recipes through the campaign export and import.

Package app wires together all application dependencies. This file implements the addons.PresetApplier interface, bridging the systems package (manifest data) and entities package (entity type creation) to auto-create entity types when a game system addon is enabled.

Package app wires together all application dependencies. This file implements the addons.SetupProvider for the Player Character Claiming addon — the first concrete extension settings/onboarding provider. It bridges the addons framework (which owns the settings page + registry) and the entities package (which owns the player-character category logic), so the addons package never imports entities (mirrors preset_applier.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IconColumns

func IconColumns() []database.IconColumn

IconColumns gathers every plugin's stored icon columns for the boot-time icon reconciler (database.ReconcileIconColumns). A plugin that adds an icon column adds it to its own IconColumns and to this list.

func PublicTextColumns

func PublicTextColumns() []database.PublicTextColumn

PublicTextColumns gathers every plugin's rich-text columns that are served as stored to all their readers, for the boot-time reconciler that removes GM-only parts (database.ReconcilePublicTextColumns). A plugin that adds one adds it to its own PublicTextColumns and to this list.

func StartupHealthCheckConfig

func StartupHealthCheckConfig(cfg *config.Config) database.HealthCheckConfig

StartupHealthCheckConfig builds the HealthCheckConfig used at boot and on demand by the admin Health tab. The critical-column pins document which migration each column came from — a deploy missing that migration fails fast with a precise error instead of a downstream 500.

Types

type App

type App struct {
	// Config holds the loaded application configuration.
	Config *config.Config

	// DB is the MariaDB connection pool shared by all plugins.
	DB *sql.DB

	// Redis is the Redis client shared for sessions, caching, rate limiting.
	Redis *redis.Client

	// Echo is the router and middleware chain that serves every request.
	Echo *echo.Echo

	// WASMPluginManager manages loaded WASM logic extension plugins.
	// Set during route registration; nil until then.
	WASMPluginManager *extensions.PluginManager

	// WASMHookDispatcher dispatches events to WASM plugins.
	// Set during route registration; nil until then.
	WASMHookDispatcher *extensions.HookDispatcher

	// PluginHealth tracks which built-in plugins have healthy schemas.
	// Used during route registration to skip degraded plugins.
	PluginHealth *database.PluginHealthRegistry

	// PluginSchemas holds the registered plugin migration configurations.
	// Used by the database explorer to re-run migrations on demand.
	PluginSchemas []database.PluginSchema

	// ShutdownCtx is canceled by ShutdownCancel when the server begins
	// graceful shutdown (cmd/server/main.go's signal handler). Long-running
	// startup background jobs (e.g. the media content-hash backfill) select
	// on it instead of context.Background() so they stop instead of working
	// against a closing DB connection (#711).
	ShutdownCtx context.Context

	// ShutdownCancel cancels ShutdownCtx. Called once, from the signal
	// handler in cmd/server/main.go.
	ShutdownCancel context.CancelFunc

	// UploadCeilingFn, when set, replaces the settings-backed media upload
	// ceiling used by the pre-CSRF size cap. Tests set it; production leaves
	// it nil.
	UploadCeilingFn func() int64

	// Maintenance is the site-wide "back in a few minutes" state a restore
	// drives. The global gate middleware and /healthz read it; it is built
	// from the backup directory so a restart mid-restore comes back closed.
	Maintenance *maintenance.State

	// PostRestoreSchema brings a freshly restored database up to this build
	// the way a normal start does. Set by cmd/server before RegisterRoutes;
	// nil skips it (tests).
	PostRestoreSchema func(ctx context.Context) error
	// contains filtered or unexported fields
}

App holds all shared dependencies and the Echo HTTP server instance. Created once at startup in main.go and used to register all routes.

func New

func New(cfg *config.Config, db *sql.DB, rdb *redis.Client, pluginHealth *database.PluginHealthRegistry, pluginSchemas []database.PluginSchema) (*App, error)

New creates a new App instance with the given dependencies and configures the Echo server with global middleware and error handling.

func (*App) RegisterRoutes

func (a *App) RegisterRoutes()

RegisterRoutes sets up all application routes. It registers public routes directly and delegates to each plugin's route registration function.

This is the single place where all routes are aggregated. When a new plugin is added, its routes are registered here.

func (*App) RegisteredPlugins

func (a *App) RegisteredPlugins() []PluginRegistration

RegisteredPlugins returns a copy of the App's registry slice, so callers can't mutate the App's internal slice.

func (*App) Shutdown

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

Shutdown stops accepting connections and waits, until ctx ends, for in-flight requests to finish. Start then returns http.ErrServerClosed.

func (*App) Start

func (a *App) Start() error

Start begins listening for HTTP requests on the configured port.

type PluginRegistration

type PluginRegistration struct {
	// Slug is the canonical identifier for this plugin. MUST match the
	// owning plugin's exported PluginSlug const so the lookup is
	// symmetric (slug → plugin code, plugin code → slug).
	Slug string

	// HealthCheck is an optional callback returning nil if the plugin is
	// operational, or an error if not. May be nil — not every plugin has
	// a schema or other failable health signal.
	HealthCheck func() error

	// StaticFS is an optional embedded filesystem of plugin-owned static
	// assets. When non-nil, App.mountPluginStatic() registers it with
	// Echo at /static/plugins/<Slug>/. Use echo.MustSubFS(<embed.FS>,
	// "static") at the registration site so the URL doesn't double the
	// "static" dir. nil = no static assets.
	StaticFS fs.FS

	// Widgets are this plugin's on-sight scripts: boot.js fetches a widget's
	// scripts the first time its data-widget mount appears on a page, so a
	// page without the widget, or a campaign with its add-on switched off,
	// never downloads them (ADR-063). nil = nothing loaded on sight.
	Widgets []PluginWidget
}

PluginRegistration is the per-plugin entry in the App's registry. Each plugin contributes exactly one entry, populated inline from RegisterRoutes at the plugin's setup point.

type PluginWidget

type PluginWidget struct {
	Name    string
	Scripts []string
}

PluginWidget names one data-widget mount and the scripts that implement it, in load order: helpers first, the script that calls Chronicle.register(Name, …) last. A path starting with "/" is a site path (shared code under /static/); any other path is relative to the plugin's own StaticFS mount.

Source Files

Jump to

Keyboard shortcuts

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