database

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package database wires SQLite connection pools and database lifecycle for the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPutDebugHook added in v0.15.0

func DefaultPutDebugHook(conn *sql.Conn) []slog.Attr

DefaultPutDebugHook is the production Put debug hook for sqlite3stat.

func EffectivePoolLimits added in v0.14.0

func EffectivePoolLimits(cfg *config.Config) (max, minIdle int64, monitorInterval time.Duration)

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

type DatabasePaths struct {
	Main   string // Path to sfpg.db
	Thumbs string // Path to thumbs.db
}

DatabasePaths holds the file paths for both application databases.

func Setup

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL