db
| Key | Type | Default |
|---|---|---|
db.provider |
string | sqlite |
db.connection_string |
string | ssoossh.db |
db.logging.* |
||
db.logging.level |
string | WARN |
db.logging.add_source |
bool | false |
db.logging.log_json |
bool | false |
db.retry_attempts |
int | 3 |
db.retry_interval |
duration | 3s |
db.max_open_conns |
int | 10 |
db.max_idle_conns |
int | 5 |
db.conn_max_lifetime |
duration | 0 |
provider
Section titled “provider”string, default sqlite
Identifies which database backend to use.
db: provider: "sqlite"connection_string
Section titled “connection_string”string, default ssoossh.db
The connection string / DSN. For SQLite this is a file path (or “:memory:” for in-memory); for PostgreSQL a standard postgres:// URL or keyword string.
db: connection_string: "ssoossh.db"logging
Section titled “logging”Configures which database queries are logged and where they are written. See DBLogging for detailed options.
logging.*
Section titled “logging.*”Log-file rotation for this destination, via the embedded timberjack logger, with the same keys and meanings as logging.* above. This destination is only split out of the main log once its filename is set; until then its records go to the general log.
logging.level
Section titled “logging.level”string, default WARN
The minimum log level for this destination, in the same form as logging.level. Empty means this destination has no threshold of its own and is filtered at logging.level with everything else.
db: logging: level: "info"logging.add_source
Section titled “logging.add_source”bool, default false
Includes the source file and line on each record.
db: logging: add_source: falselogging.log_json
Section titled “logging.log_json”bool, default false
Writes JSON instead of text. Text is meant to be read, not parsed: the message is written as bare prose so quoted values in it are not escaped, which is not a machine-readable format. Set this wherever a log collector has to pull fields back out.
db: logging: log_json: falseretry_attempts
Section titled “retry_attempts”int, default 3
The maximum number of connection attempts before giving up. Zero or negative disables retries (will fail immediately on the first error). Applies to both SQLite (typically succeeds immediately) and PostgreSQL (may retry on transient network failures).
db: retry_attempts: 3retry_interval
Section titled “retry_interval”duration, default 3s
The time to wait between connection retry attempts. Only used if retry_attempts > 1. Applies to both SQLite and PostgreSQL.
db: retry_interval: 3smax_open_conns
Section titled “max_open_conns”int, default 10
Sets the maximum number of open connections to the database. Zero means Go’s default (typically 2). For file-backed SQLite, keep this modest: writes serialize on the write lock regardless, so high counts just queue without benefit. For PostgreSQL, scale with expected concurrency. This is ignored for in-memory SQLite, which is always forced to 1.
db: max_open_conns: 10max_idle_conns
Section titled “max_idle_conns”int, default 5
Sets the maximum number of idle connections held open. Zero means Go’s default (typically 2, same as max_open_conns). Keep this proportionate to max_open_conns — they are not independent; a high max_open_conns with a low max_idle_conns causes expensive churn.
db: max_idle_conns: 5conn_max_lifetime
Section titled “conn_max_lifetime”duration, default 0
Sets the maximum amount of time a connection can be reused. Zero disables the limit (connections are reused indefinitely). Useful for breaking stale connections in long-running deployments, but typically not necessary with a well-behaved database server.
db: conn_max_lifetime: 0