Documentation
¶
Overview ¶
Package config is tq's single deployment description: where the state lives (driver, path/DSN), which IO tier the sqlite homes run at (SyncPolicy), and whether the read-model projection is enabled. Every layer that opens a database — the sqlitev4 driver, the composition root's projection engine, the CLI flags — consumes THIS struct, so exactly one pragma builder and one env reader exist in the repo (ADR-0022's deployment lane).
The package is a leaf: no internal dependencies, stdlib only.
Index ¶
Constants ¶
const EnvSyncPolicy = "TQ_SQLITE_SYNC"
EnvSyncPolicy is the environment variable that overrides the sync tier; the name and the full|normal|off vocabulary are a deployment contract (existing operators' settings keep their meaning).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deployment ¶
type Deployment struct {
Driver Driver
DBPath string // sqlite file path
DSN string // postgres DSN (postgres://…)
SyncPolicy SyncPolicy // sqlite IO tier (both sqlite homes)
ReadModelEnabled bool // serve-time projection toggle
}
Deployment is the one description of where tq's state lives. Exactly one of DBPath (sqlite) or DSN (postgres) is meaningful — the driver decides which — and Validate makes a mixed or empty deployment an error at construction instead of a mystery at open.
func FromFlags ¶
func FromFlags(store string, readModel bool) (Deployment, error)
FromFlags builds the Deployment from the CLI-shaped store value and the sync-policy environment: a bare path is a sqlite file, a postgres:// URL selects the shared-server driver. The environment merge happens here — the ONE TQ_SQLITE_SYNC reader — so the struct every opener consumes is already resolved.
func Postgres ¶
func Postgres(dsn string) Deployment
Postgres returns a postgres Deployment over dsn.
func SQLite ¶
func SQLite(path string) Deployment
SQLite returns a sqlite Deployment over path at the default sync tier.
func (Deployment) DLQPragmas ¶ added in v0.3.4
func (d Deployment) DLQPragmas() []string
DLQPragmas renders the DSN pragma list for the projection home's dead-letter sidecar: a plain sql.Open (not the engine, which would prepend WAL and busy_timeout itself), so the list is complete. Same sync-tier knob as both homes — the sidecar is diagnostic, but the operator's tier decision is the ONE tier decision.
func (Deployment) ProjectionPragmas ¶
func (d Deployment) ProjectionPragmas() []string
ProjectionPragmas renders the caller-side pragmas the projection-home engine takes (the sqliteengine factory prepends journal_mode=WAL and busy_timeout on every connection, so the caller list carries only the tier and the cache budget). Derived from the same SyncPolicy as the queue home: one knob, both sqlite homes.
func (Deployment) QueuePragmas ¶
func (d Deployment) QueuePragmas() []string
QueuePragmas renders the sqlite connection pragmas for the QUEUE home in DSN order — the ONE pragma literal in the repo (the struct's builder). The order is load-bearing: journal_mode must precede synchronous so WAL is active before the tier applies.
func (Deployment) Validate ¶
func (d Deployment) Validate() error
Validate enforces the deployment's shape invariants.
type SyncPolicy ¶
type SyncPolicy string
SyncPolicy is tq's sqlite IO durability tier (the TQ_SQLITE_SYNC vocabulary): NORMAL is the steady-state default (fsync at WAL checkpoints only — the queue's recovery model tolerates a lost tail); FULL restores per-commit fsync; OFF disables fsync entirely.
const ( SyncFull SyncPolicy = "full" SyncNormal SyncPolicy = "normal" SyncOff SyncPolicy = "off" )
func SyncPolicyFromEnv ¶
func SyncPolicyFromEnv() (SyncPolicy, error)
SyncPolicyFromEnv reads EnvSyncPolicy and validates the vocabulary. Empty means the default tier; the case-insensitive full|normal|off contract and the error wording match the pre-struct sqlitev4 reader byte for byte, so existing operators' environments keep their exact meaning.