db_session

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Default

type Default struct {
	// contains filtered or unexported fields
}

func NewProdFactory

func NewProdFactory(config *config.DatabaseConfig) *Default

func (*Default) CheckConnection

func (f *Default) CheckConnection() error

func (*Default) Close

func (f *Default) Close() error

Close will close the connection to the database. THIS MUST **NOT** BE CALLED UNTIL THE SERVER/PROCESS IS EXITING!! This should only ever be called once for the entire duration of the application and only at the end.

func (*Default) DirectDB

func (f *Default) DirectDB() *sql.DB

func (*Default) Init

func (f *Default) Init(config *config.DatabaseConfig)

Init will initialize a singleton connection as needed and return the same instance. Go includes database connection pooling in the platform. Gorm uses the same and provides a method to clone a connection via New(), which is safe for use by concurrent Goroutines.

func (*Default) New

func (f *Default) New(ctx context.Context) *gorm.DB

func (*Default) NewListener

func (f *Default) NewListener(ctx context.Context, channel string, callback func(id string))

func (*Default) ReconfigureLogger

func (f *Default) ReconfigureLogger(level gormlogger.LogLevel)

ReconfigureLogger changes the GORM logger level at runtime

func (*Default) ResetDB

func (f *Default) ResetDB()

type LoggerReconfigurable

type LoggerReconfigurable interface {
	ReconfigureLogger(level logger.LogLevel)
}

LoggerReconfigurable allows runtime reconfiguration of the database logger

type Test

type Test struct {
	// contains filtered or unexported fields
}

func NewTestFactory

func NewTestFactory(config *config.DatabaseConfig) *Test

func (*Test) CheckConnection

func (f *Test) CheckConnection() error

CheckConnection checks to ensure a connection is present

func (*Test) Close

func (f *Test) Close() error

func (*Test) DirectDB

func (f *Test) DirectDB() *sql.DB

func (*Test) Init

func (f *Test) Init(config *config.DatabaseConfig)

Init will: - initialize a template1 DB with migrations - rebuild AMS DB from template1 - return a new connection factory Go includes database connection pooling in the platform. Gorm uses the same and provides a method to clone a connection via New(), which is safe for use by concurrent Goroutines.

func (*Test) New

func (f *Test) New(ctx context.Context) *gorm.DB

func (*Test) NewListener

func (f *Test) NewListener(ctx context.Context, channel string, callback func(id string))

func (*Test) ReconfigureLogger

func (f *Test) ReconfigureLogger(level gormlogger.LogLevel)

ReconfigureLogger changes the GORM logger level at runtime

func (*Test) ResetDB

func (f *Test) ResetDB()

type Testcontainer

type Testcontainer struct {
	// contains filtered or unexported fields
}

func NewTestcontainerFactory

func NewTestcontainerFactory(config *config.DatabaseConfig) *Testcontainer

NewTestcontainerFactory creates a SessionFactory using testcontainers. This starts a real PostgreSQL container for integration testing.

func (*Testcontainer) CheckConnection

func (f *Testcontainer) CheckConnection() error

func (*Testcontainer) Close

func (f *Testcontainer) Close() error

func (*Testcontainer) DirectDB

func (f *Testcontainer) DirectDB() *sql.DB

func (*Testcontainer) Init

func (f *Testcontainer) Init(config *config.DatabaseConfig)

func (*Testcontainer) New

func (f *Testcontainer) New(ctx context.Context) *gorm.DB

func (*Testcontainer) NewListener

func (f *Testcontainer) NewListener(ctx context.Context, channel string, callback func(id string))

func (*Testcontainer) ReconfigureLogger

func (f *Testcontainer) ReconfigureLogger(level gormlogger.LogLevel)

ReconfigureLogger changes the GORM logger level at runtime

func (*Testcontainer) ResetDB

func (f *Testcontainer) ResetDB()

Jump to

Keyboard shortcuts

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