Documentation
¶
Overview ¶
Package database wires SQLite connection pools and database lifecycle for the server.
Index ¶
- func DefaultPutDebugHook(conn *sql.Conn) []slog.Attr
- func EffectivePoolLimits(cfg *config.Config) (max, minIdle int64, monitorInterval time.Duration)
- func RecreatePoolsWithConfig(ctx context.Context, paths DatabasePaths, cfg *config.Config, ...) (*dbconnpool.DbSQLConnPool, *dbconnpool.DbSQLConnPool, error)
- type DatabasePaths
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPutDebugHook ¶ added in v0.15.0
DefaultPutDebugHook is the production Put debug hook for sqlite3stat.
func EffectivePoolLimits ¶ added in v0.14.0
EffectivePoolLimits returns the connection pool limits (max connections, min idle connections) and monitor interval that would be applied for the given config. A nil config falls back to config.DefaultConfig (100/10/1m), and a non-positive monitor interval is clamped to the default (1m) so the pool monitor always runs. Min idle 0 is preserved as-is (effective 0).
func RecreatePoolsWithConfig ¶ added in v0.3.0
func RecreatePoolsWithConfig(ctx context.Context, paths DatabasePaths, cfg *config.Config, oldRwPool, oldRoPool *dbconnpool.DbSQLConnPool) (*dbconnpool.DbSQLConnPool, *dbconnpool.DbSQLConnPool, error)
RecreatePoolsWithConfig closes old pools and creates new ones with the given config. This is used when configuration is loaded after initial pool creation to honor database-stored pool settings during startup.
Types ¶
type DatabasePaths ¶ added in v0.3.0
DatabasePaths holds the file paths for both application databases.
func Setup ¶
func Setup(ctx context.Context, rootDir string, cfg *config.Config) (DatabasePaths, *dbconnpool.DbSQLConnPool, *dbconnpool.DbSQLConnPool, error)
Setup initializes the database environment: 1. Sets up the directory struct 2. Runs schema migrations 3. Establishes connection pools (RW/RO) 4. Ensures root folder entry exists 5. Schedules periodic optimization