connection

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 10 Imported by: 0 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 PostgresConfig

type PostgresConfig struct {
	Host     string
	Port     int
	Database string
	Username string
	Password string
	SSLMode  string
	TimeZone string

	// Connection Pool Settings
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
	ConnMaxIdleTime time.Duration

	// Timeouts
	ConnectTimeout   time.Duration
	StatementTimeout time.Duration

	// Logging
	LogLevel      logger.LogLevel
	SlowThreshold time.Duration

	// Advanced Settings
	ApplicationName string
	SearchPath      string
	PgBouncerMode   bool
}

PostgresConfig configuración para conexión PostgreSQL

func DefaultPostgresConfig

func DefaultPostgresConfig() *PostgresConfig

DefaultPostgresConfig retorna configuración por defecto

func NewPostgresConfigFromEnv

func NewPostgresConfigFromEnv() *PostgresConfig

NewPostgresConfigFromEnv crea configuración desde variables de entorno

func (*PostgresConfig) Clone

func (c *PostgresConfig) Clone() *PostgresConfig

Clone crea una copia de la configuración

func (*PostgresConfig) Validate

func (c *PostgresConfig) Validate() error

ValidateConfig valida la configuración

type PostgresConnectionManager

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

PostgresConnectionManager maneja conexiones PostgreSQL

func NewPostgresConnectionManager

func NewPostgresConnectionManager(config *PostgresConfig, logger *logrus.Logger) *PostgresConnectionManager

NewPostgresConnectionManager crea un nuevo manager de conexiones

func (*PostgresConnectionManager) Close

func (m *PostgresConnectionManager) Close() error

Close cierra todas las conexiones

func (*PostgresConnectionManager) Connect

Connect establece todas las conexiones de base de datos

func (*PostgresConnectionManager) ExecuteInGORMTransaction

func (m *PostgresConnectionManager) ExecuteInGORMTransaction(fn func(tx *gorm.DB) error) error

ExecuteInGORMTransaction ejecuta una función dentro de una transacción GORM

func (*PostgresConnectionManager) ExecuteInTransaction

func (m *PostgresConnectionManager) ExecuteInTransaction(ctx context.Context, fn func(tx *sql.Tx) error) error

ExecuteInTransaction ejecuta una función dentro de una transacción

func (*PostgresConnectionManager) GetDSN

func (m *PostgresConnectionManager) GetDSN() string

GetDSN retorna el DSN de conexión

func (*PostgresConnectionManager) GetGORM

func (m *PostgresConnectionManager) GetGORM() *gorm.DB

GetGORM retorna la conexión GORM

func (*PostgresConnectionManager) GetSQL

func (m *PostgresConnectionManager) GetSQL() *sql.DB

GetSQL retorna la conexión database/sql

func (*PostgresConnectionManager) GetSQLX

func (m *PostgresConnectionManager) GetSQLX() *sqlx.DB

GetSQLX retorna la conexión SQLX

func (*PostgresConnectionManager) GetStats

func (m *PostgresConnectionManager) GetStats() map[string]interface{}

GetStats retorna estadísticas de las conexiones

func (*PostgresConnectionManager) Ping

Ping verifica la conectividad de todas las conexiones

func (*PostgresConnectionManager) RunMigrations

func (m *PostgresConnectionManager) RunMigrations(models ...interface{}) error

RunMigrations ejecuta migraciones usando GORM

Jump to

Keyboard shortcuts

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