Documentation
¶
Overview ¶
Package config loads application configuration from environment variables. All configuration is immutable after initialization (CFG-2).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DBPath is the path to the SQLite database file.
DBPath string
// PeeringDBBaseURL is the base URL for the PeeringDB API.
PeeringDBBaseURL string
// SyncToken is the shared secret for on-demand sync trigger authentication.
SyncToken string
// SyncInterval is the duration between automatic sync runs.
SyncInterval time.Duration
// IncludeDeleted controls whether objects with status=deleted are synced.
IncludeDeleted bool
// ListenAddr is the address the HTTP server binds to.
ListenAddr string
// CORSOrigins is a comma-separated list of allowed CORS origins.
// Configured via PDBPLUS_CORS_ORIGINS. Default is "*".
CORSOrigins string
// DrainTimeout is the graceful shutdown drain timeout.
// Configured via PDBPLUS_DRAIN_TIMEOUT. Default is 10 seconds.
DrainTimeout time.Duration
// OTelSampleRate is the trace sampling ratio (0.0 to 1.0).
// Configured via PDBPLUS_OTEL_SAMPLE_RATE. Default is 1.0 (always sample) per D-02.
OTelSampleRate float64
// SyncStaleThreshold is the maximum age of sync data before health reports degraded.
// Configured via PDBPLUS_SYNC_STALE_THRESHOLD. Default is 24h per D-12.
SyncStaleThreshold time.Duration
// SyncMode controls whether sync uses full re-fetch or incremental delta fetch.
// Configured via PDBPLUS_SYNC_MODE. Default is "full".
SyncMode SyncMode
// PublicTier is the resolved visibility tier for anonymous HTTP callers.
// Configured via PDBPLUS_PUBLIC_TIER. Default TierPublic admits only
// visible="Public" rows. Setting PDBPLUS_PUBLIC_TIER=users elevates
// anonymous callers to TierUsers for private-instance deployments
// (D-11, SYNC-03). Parsed case-sensitive lowercase only (D-12); any
// other value is a fail-fast startup error per GO-CFG-1.
PublicTier privctx.Tier
// PeeringDBAPIKey is the optional PeeringDB API key for authenticated access.
// Configured via PDBPLUS_PEERINGDB_API_KEY. Empty string means unauthenticated.
PeeringDBAPIKey string
// StreamTimeout is the maximum duration for a single streaming RPC.
// Configured via PDBPLUS_STREAM_TIMEOUT. Default is 60 seconds.
StreamTimeout time.Duration
// CSPEnforce controls whether the CSP middleware serves the enforcing
// Content-Security-Policy header (true) or the Content-Security-Policy-Report-Only
// header (false). Configured via PDBPLUS_CSP_ENFORCE. Default is false per SEC-07
// rollout strategy — enforcement is opt-in per deploy through v1.13.
CSPEnforce bool
// SyncMemoryLimit is the peak Go heap ceiling (bytes) checked after
// the sync worker's Phase A fetch pass completes and before the
// database transaction opens. If runtime.ReadMemStats reports
// HeapAlloc above this value, the sync aborts with a WARN log and
// returns sync.ErrSyncMemoryLimitExceeded. The next scheduled sync
// retries normally after the current batches are reclaimed by GC.
//
// Configured via PDBPLUS_SYNC_MEMORY_LIMIT. Default is 400MB —
// matches the DEBT-03 regression gate in BenchmarkSyncWorker_FullMemoryPeak
// and leaves 112 MB headroom under the 512 MB Fly.io VM cap per
// v1.13 hard constraint. Set to 0 to disable the guardrail (local
// dev only; guardrail is defense-in-depth against runtime memory
// spikes that exceed what the benchmark harness measured).
//
// Unit suffix is required (KB/MB/GB/TB, base 1024); bare numbers
// are rejected for unambiguous operator configuration.
SyncMemoryLimit int64
// HeapWarnBytes is the peak Go heap threshold (bytes) above which the
// sync worker emits slog.Warn("heap threshold crossed", ...) at the
// end of each sync cycle. The OTel span attribute
// pdbplus.sync.peak_heap_mib is emitted regardless; only the Warn is
// threshold-gated. Configured via PDBPLUS_HEAP_WARN_MIB (integer MiB,
// no unit suffix). Default 400 MiB matches the Fly 512 MB VM cap minus
// a 112 MB safety margin (D-04). Zero disables the warn (attr still
// emitted so dashboards retain timeseries).
//
// SEED-001: sustained breach is the escalation signal for considering
// PDBPLUS_SYNC_MODE=incremental.
HeapWarnBytes int64
// RSSWarnBytes is the peak OS RSS threshold (bytes) above which the
// sync worker emits slog.Warn at the end of each sync cycle. Read from
// /proc/self/status VmHWM on Linux; skipped on other OSes (the RSS
// attr is then omitted — it is not set to zero). Configured via
// PDBPLUS_RSS_WARN_MIB (integer MiB, no unit suffix). Default 384 MiB.
// Zero disables the warn.
RSSWarnBytes int64
}
Config holds all application configuration. Immutable after Load returns.
Click to show internal directories.
Click to hide internal directories.