database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionManager

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

ConnectionManager manages database connections with pooling and health checks

func NewConnectionManager

func NewConnectionManager(cfg *config.DatabaseConfig) (*ConnectionManager, error)

NewConnectionManager creates a new connection manager

func (*ConnectionManager) Close

func (cm *ConnectionManager) Close() error

Close closes all database connections

func (*ConnectionManager) GetAllReadDBs

func (cm *ConnectionManager) GetAllReadDBs() []*gorm.DB

GetAllReadDBs returns all read replica connections

func (*ConnectionManager) GetHealthResults

func (cm *ConnectionManager) GetHealthResults() <-chan HealthCheckResult

GetHealthResults returns the health check results channel

func (*ConnectionManager) GetPrimaryDB

func (cm *ConnectionManager) GetPrimaryDB() *gorm.DB

GetPrimaryDB returns the primary database connection

func (*ConnectionManager) GetReadDB

func (cm *ConnectionManager) GetReadDB() *gorm.DB

GetReadDB returns a read replica database connection (round-robin)

func (*ConnectionManager) GetStats

func (cm *ConnectionManager) GetStats() map[string]interface{}

GetStats returns connection statistics

func (*ConnectionManager) IsHealthy

func (cm *ConnectionManager) IsHealthy() bool

IsHealthy returns true if all connections are healthy

type HealthCheckResult

type HealthCheckResult struct {
	DB      *gorm.DB
	Healthy bool
	Error   error
	Time    time.Time
}

HealthCheckResult represents the result of a health check

Jump to

Keyboard shortcuts

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