database

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultStatementTimeout                = 60 * time.Second
	DefaultIdleInTransactionSessionTimeout = 30 * time.Second
)

Functions

func Conn

func Conn() *gorm.DB

func DB added in v0.26.0

func DB(ctx context.Context) *gorm.DB

DB returns a request-scoped GORM handle so SQL trace hooks can attach to the active OpenTelemetry span in ctx.

func OpenDedicatedSQLDB added in v0.26.0

func OpenDedicatedSQLDB(applicationName string, maxOpenConns int) (*sql.DB, error)

func PoolStats added in v0.26.0

func PoolStats() (sql.DBStats, error)

func TruncateTables

func TruncateTables() error

func VerifyTestDatabase added in v0.28.0

func VerifyTestDatabase(db *gorm.DB) error

VerifyTestDatabase returns an error unless the connection points at a test database (name ending in _test). Call it before destructive test helpers so a misconfigured DB_NAME fails loudly instead of wiping a developer database.

Types

type Config

type Config struct {
	StatementTimeout                time.Duration
	IdleInTransactionSessionTimeout time.Duration
}

func LoadConfig added in v0.19.0

func LoadConfig() Config

type DSNConfig added in v0.19.0

type DSNConfig struct {
	Host            string
	Port            string
	Name            string
	User            string
	Pass            string
	Ssl             string
	ApplicationName string
}

Jump to

Keyboard shortcuts

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