Skip to main content

Module config

Module config 

Source
Expand description

Database configuration types.

This module contains the canonical definitions of all database configuration structures used throughout the system. These types are deserialized directly from Figment configuration.

§Configuration Precedence Rules

The database configuration system follows a strict precedence hierarchy when merging global server configurations with module-specific overrides:

PrioritySourceDescriptionExample
1 (Highest)Module params mapKey-value parameters in module configparams: {synchronous: "FULL"}
2Module DSN query paramsParameters in module-level DSNsqlite://file.db?synchronous=NORMAL
3Module fieldsIndividual connection fieldshost: "localhost", port: 5432
4Module DSN baseCore DSN without query paramspostgres://user:pass@host/db
5Server params mapKey-value parameters in server configGlobal server params
6Server DSN query paramsParameters in server-level DSNServer DSN query string
7Server fieldsIndividual connection fields in serverServer host, port, etc.
8 (Lowest)Server DSN baseCore server DSN without query paramsBase server connection string

§Merge Rules

  1. Field Precedence: Module fields always override server fields
  2. DSN Precedence: Module DSN overrides server DSN completely
  3. Params Merging: params maps are merged, with module params taking precedence
  4. Pool Configuration: Module pool config overrides server pool config entirely
  5. SQLite Paths: file/path fields are module-only and never inherited from servers

§Conflict Detection

The system validates configurations and returns [DbError::ConfigConflict] for:

  • SQLite DSN with server fields (host/port)
  • Non-SQLite DSN with SQLite fields (file/path)
  • Both file and path specified for SQLite
  • SQLite fields mixed with server connection fields

Structs§

DbConnConfig
Reusable DB connection config for both global servers and modules. DSN must be a FULL, valid DSN if provided (dsn crate compliant).
GlobalDatabaseConfig
Global database configuration with server-based DBs.
PoolCfg

Enums§

DbEngineCfg
Serializable engine selector for configuration.