Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
Database string `json:"database" yaml:"database"`
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
SSLMode string `json:"ssl_mode" yaml:"ssl_mode"`
}
Config holds database connection configuration
type ConnectionPool ¶
type ConnectionPool struct {
Config *Config
DB *gorm.DB
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
}
ConnectionPool manages database connections
func NewConnectionPool ¶
func NewConnectionPool(config *Config) *ConnectionPool
NewConnectionPool creates a new connection pool
func (*ConnectionPool) Close ¶
func (p *ConnectionPool) Close() error
Close closes the database connection
func (*ConnectionPool) Connect ¶
func (p *ConnectionPool) Connect() error
Connect establishes a connection to the database
type HealthCheck ¶
type HealthCheck struct {
Pool *ConnectionPool
Timeout time.Duration
}
HealthCheck provides database health checking functionality
func NewHealthCheck ¶
func NewHealthCheck(pool *ConnectionPool) *HealthCheck
NewHealthCheck creates a new health check
func (*HealthCheck) Check ¶
func (h *HealthCheck) Check(ctx context.Context) *core.HealthStatus
Check performs a health check on the database
type Repository ¶
Repository provides base repository functionality
func NewRepository ¶
func NewRepository(db *gorm.DB) *Repository
NewRepository creates a new repository
func (*Repository) Migrate ¶
func (r *Repository) Migrate(models ...interface{}) error
Migrate runs database migrations for the given models
func (*Repository) Transaction ¶
func (r *Repository) Transaction(fn func(*gorm.DB) error) error
Transaction executes a function within a database transaction
Click to show internal directories.
Click to hide internal directories.