Skip to content

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

string, default sqlite

Identifies which database backend to use.

db:
provider: "sqlite"

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"

Configures which database queries are logged and where they are written. See DBLogging for detailed options.

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.

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"

bool, default false

Includes the source file and line on each record.

db:
logging:
add_source: false

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: false

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: 3

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: 3s

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: 10

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: 5

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