Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
Host string `json:"host" yaml:"host"`
Port string `json:"port" yaml:"port"`
UserName string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
}
ConnectionConfig defines the configuration for a single database connection.
func (*ConnectionConfig) DSN ¶
func (c *ConnectionConfig) DSN(cfg *DBConn) string
DSN generates a PostgreSQL connection string.
type DBConn ¶
type DBConn struct {
// Primary configuration.
Master ConnectionConfig `json:"master" yaml:"master"`
// Replica configuration list.
Replicas []ConnectionConfig `json:"replicas" yaml:"replicas"`
// Connection pool settings.
MaxIdleConns int `json:"maxIdleConns" yaml:"maxIdleConns"`
MaxOpenConns int `json:"maxOpenConns" yaml:"maxOpenConns"`
ConnMaxLifetime time.Duration `json:"connMaxLifetime" yaml:"connMaxLifetime"`
// Database name.
Database string `json:"database" yaml:"database"`
// PostgreSQL-specific settings.
Schema string `json:"schema" yaml:"schema"`
SearchPath string `json:"searchPath" yaml:"searchPath"`
SSLMode string `json:"sslMode" yaml:"sslMode"`
// PostgreSQL timeout settings.
StatementTimeout time.Duration `json:"statementTimeout" yaml:"statementTimeout"` // statement_timeout
LockTimeout time.Duration `json:"lockTimeout" yaml:"lockTimeout"` // lock_timeout
IdleInTransactionSessionTimeout time.Duration `json:"idleInTransactionSessionTimeout" yaml:"idleInTransactionSessionTimeout"` // idle_in_transaction_session_timeout
// pgx-specific settings.
ApplicationName string `json:"applicationName" yaml:"applicationName"`
RuntimeParams map[string]string `json:"runtimeParams" yaml:"runtimeParams"`
HealthCheckPeriod time.Duration `json:"healthCheckPeriod" yaml:"healthCheckPeriod"`
// Preset configuration for default connection behavior.
// Optional values: "", PresetSupabaseTransaction.
Preset Preset `json:"preset" yaml:"preset"`
// GORM settings that override preset behavior.
GORM *GORMConfig `json:"gorm" yaml:"gorm"`
// PGX settings at the driver layer.
PGX *PGXConfig `json:"pgx" yaml:"pgx"`
}
DBConn combines primary and replica configurations.
type GORMConfig ¶ added in v1.1.0
type GORMConfig struct {
// Skip GORM default implicit transactions.
// Useful for transaction poolers such as Supabase/pgBouncer.
SkipDefaultTransaction *bool `json:"skipDefaultTransaction" yaml:"skipDefaultTransaction"`
// Disable server-side prepared statements.
// Useful for transaction poolers.
PrepareStmt *bool `json:"prepareStmt" yaml:"prepareStmt"`
}
GORMConfig defines behavior settings at the GORM layer.
Click to show internal directories.
Click to hide internal directories.