config

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config loads runtime configuration from the environment (12-factor). It is imported only by the composition root (cmd/server); no other package reads the environment directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HTTPAddr        string        // listen address, e.g. ":8080"
	ShutdownTimeout time.Duration // graceful shutdown grace period
	PresignTTL      time.Duration // lifetime of presigned download URLs
	MaxUploadBytes  int64         // reject uploads larger than this; 0 disables the cap

	Postgres Postgres
	Storage  Storage
	GC       GC
}

Config is the fully-resolved runtime configuration.

func Load

func Load() (Config, error)

Load reads configuration from the environment, applying defaults. It returns an error if a required value is missing or malformed. As of Phase 1 the Postgres and S3 settings are required — the server connects to both at boot.

type GC

type GC struct {
	Interval       time.Duration
	GracePeriod    time.Duration
	IdempotencyTTL time.Duration
}

GC configures the background reconciliation sweep. A non-positive Interval disables it. GracePeriod is how old an unreferenced object must be before it is treated as an orphan — it must exceed the longest plausible upload so an in-flight write (object stored, row not yet committed) is never reclaimed. IdempotencyTTL is how long upload idempotency keys are retained before the sweep expires them (non-positive disables expiry).

type Postgres

type Postgres struct {
	DSN string // pgx connection string / URL
}

Postgres holds the metadata database connection settings.

type Storage

type Storage struct {
	Endpoint       string // host:port for service-side I/O, no scheme
	PublicEndpoint string // host:port clients are redirected to; defaults to Endpoint
	Region         string
	AccessKey      string
	SecretKey      string
	Bucket         string
	UseSSL         bool // TLS for the service-side endpoint
	PublicUseSSL   bool // TLS scheme for presigned URLs; defaults to UseSSL
}

Storage holds the S3-compatible backend settings.

Endpoint is where the service performs all object I/O (often an internal network name like "minio:9000"). PublicEndpoint is the host baked into presigned URLs handed back to clients; it defaults to Endpoint and only differs when external callers reach the store by a different name than the service does. The host is part of the SigV4 signature, so presigned URLs are signed against PublicEndpoint directly — the host cannot be rewritten after.

Jump to

Keyboard shortcuts

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