Documentation
¶
Overview ¶
Package app is the composition root: it wires configuration, the platform runtime, logging, caches, and API clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrecheckConfig ¶
PrecheckConfig validates configuration existence without loading it: an explicitly named file must exist, and a legacy Ruby-DSL configuration is rejected. The CLI runs this on every command at parse time — Ruby loads the configuration eagerly at boot, so even `version` fails on a broken setup — while full parsing stays lazy in App construction.
Types ¶
type App ¶
type App struct {
Config config.Config
Runtime *platform.Runtime
Logger *slog.Logger
// PortalAPI returns the MOD Portal client, wired with the api cache and
// retry as Client → CacheTransport → Retry (retry outermost, as in Ruby).
PortalAPI func() (*api.MODPortalAPI, error)
// Downloader returns the MOD file downloader, wired as Client → Retry
// (no cache decorator: the downloader manages its own download-type
// cache directly, matching Ruby's download_http_client).
Downloader func() (*transfer.Downloader, error)
// MODDownloadAPI returns the client for building authenticated MOD
// download URLs. Credentials resolve lazily on first use, not here, so
// commands that never actually download never require
// FACTORIO_USERNAME/FACTORIO_TOKEN or player-data.json.
MODDownloadAPI func() (*api.MODDownloadAPI, error)
// ManagementAPI returns the client for API-key operations (upload,
// edit, images), wired as Client → Retry with no cache. The API key
// resolves lazily on first use, so commands only require
// FACTORIO_API_KEY when a management operation actually runs.
ManagementAPI func() (*api.MODManagementAPI, error)
// GameDownloadAPI returns the client for the game download endpoints,
// wired like PortalAPI (api cache + retry, as in Ruby's
// api_http_client); the actual file download goes through Downloader.
GameDownloadAPI func() (*api.GameDownloadAPI, error)
// contains filtered or unexported fields
}
App holds the application-wide object graph. Expensive components are built lazily on first use, memoized via sync.OnceValues.
func (*App) Caches ¶
func (a *App) Caches() ([]NamedCache, error)
Caches returns the configured caches. The fixed order (download, api, info_json — the Ruby config definition order) keeps output deterministic; a map would randomize it per run. Instances are built fresh — cache state lives on disk, so they can coexist with the ones inside the API clients.
func (*App) RequireGameStopped ¶
RequireGameStopped fails when Factorio is running; commands that modify game files call this first.
type NamedCache ¶
NamedCache pairs a configured cache with its name and TTL.
type Options ¶
type Options struct {
// ConfigPath is the explicitly requested configuration file (the
// --config-path flag). When empty, FACTORIX_CONFIG is consulted, then
// the default location (used only if present).
ConfigPath string
// LogLevel overrides the configured log_level when non-empty.
LogLevel string
}
Options select the configuration and log level.