database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPingTimeout is the default timeout for database ping operations
	DefaultPingTimeout = 5 * time.Second
	// MinArgsLength represents the minimum number of arguments needed for a query
	MinArgsLength = 2

	// ConnectionPoolWarningThreshold is the percentage of max connections that triggers a warning
	ConnectionPoolWarningThreshold = 0.8
	// ConnectionPoolPercentageMultiplier is used to convert ratio to percentage
	ConnectionPoolPercentageMultiplier = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GormDB added in v0.1.5

type GormDB struct {
	*gorm.DB
	// contains filtered or unexported fields
}

GormDB wraps the GORM database connection

func New added in v0.1.5

func New(cfg *config.Config, appLogger logging.Logger) (*GormDB, error)

New creates a new GORM database connection

func (*GormDB) Close added in v0.1.5

func (db *GormDB) Close() error

Close closes the database connection

func (*GormDB) MonitorConnectionPool added in v0.1.5

func (db *GormDB) MonitorConnectionPool(ctx context.Context)

MonitorConnectionPool periodically checks the database connection pool status

func (*GormDB) Ping added in v0.1.5

func (db *GormDB) Ping(ctx context.Context) error

type GormLogWriter added in v0.1.5

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

GormLogWriter implements io.Writer for GORM logger

func (*GormLogWriter) Error added in v0.1.5

func (w *GormLogWriter) Error(msg string, err error)

Error implements logger.Writer interface

func (*GormLogWriter) Printf added in v0.1.5

func (w *GormLogWriter) Printf(format string, args ...any)

Printf implements logger.Writer interface

func (*GormLogWriter) Write added in v0.1.5

func (w *GormLogWriter) Write(p []byte) (n int, err error)

Write implements io.Writer interface

Jump to

Keyboard shortcuts

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