db

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

@index Database connection and search-backend selection helpers for SQLite and PostgreSQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigurePool

func ConfigurePool(sqlDB SQLDBPool, driver string)

ConfigurePool applies database-specific connection pool settings. @intent apply connection-pool limits that match each database driver's concurrency model. @domainRule sqlite is pinned to MaxOpenConns=1 because it supports only one writer at a time. @mutates sqlDB connection-pool settings.

func NewSearchBackend

func NewSearchBackend(driver string) search.Backend

NewSearchBackend selects the search backend for the database driver. @intent select the full-text search backend implementation that matches the active database driver. @domainRule postgres uses the PostgreSQL backend and every other driver falls back to the SQLite backend.

func Open

func Open(driver, dsn string) (*gorm.DB, error)

Open creates a configured GORM connection for sqlite or postgres. @intent centralize driver-specific GORM initialization and pool setup behind one entry point. @requires driver must be sqlite or postgres and dsn must match the selected driver. @ensures returns a configured GORM connection with pool settings applied for the selected driver. @sideEffect enables SQLite WAL and busy_timeout pragmas when driver is sqlite.

Types

type SQLDBPool

type SQLDBPool interface {
	SetMaxOpenConns(int)
	SetMaxIdleConns(int)
	SetConnMaxLifetime(time.Duration)
	SetConnMaxIdleTime(time.Duration)
}

SQLDBPool abstracts configurable SQL connection pool knobs. @intent abstract the pool configuration API so both real sql.DB handles and test doubles can share the same seam.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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