Documentation
¶
Index ¶
- func ApplyMigrationPoolTuning(db *gorm.DB) error
- func ApplyPoolTuning(db *gorm.DB, config *Config, logger ...schemas.Logger) error
- func BuildDSN(config *Config) string
- func Close(db *gorm.DB, logger schemas.Logger)
- func Open(dsn string, config *Config, logger gormlogger.Interface) (*gorm.DB, error)
- func RunPasswordCommand(ctx context.Context, config *PasswordCommandConfig) (string, error)
- func Validate(config *Config, requireStaticPassword bool) error
- type Config
- type PasswordCommandConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyMigrationPoolTuning ¶ added in v1.5.5
ApplyMigrationPoolTuning pins a throwaway migration pool to a minimal size. Migration pools are opened, used for serial DDL, and closed; without this they inherit database/sql's defaults, where MaxOpenConns is unlimited.
func ApplyPoolTuning ¶
ApplyPoolTuning applies MaxIdleConns, MaxOpenConns, ConnMaxLifetime, and ConnMaxIdleTime. When a logger is supplied the effective pool shape is logged once, so operators can size against the server's max_connections without reading source — note that logstore and configstore open separate pools, so a pod's ceiling is the sum across them.
func RunPasswordCommand ¶
func RunPasswordCommand(ctx context.Context, config *PasswordCommandConfig) (string, error)
RunPasswordCommand executes a configured password command and returns stdout.
Types ¶
type Config ¶
type Config struct {
Host *schemas.SecretVar `json:"host"`
Port *schemas.SecretVar `json:"port"`
User *schemas.SecretVar `json:"user"`
Password *schemas.SecretVar `json:"password"`
PasswordCommand *PasswordCommandConfig `json:"password_command,omitempty"`
DBName *schemas.SecretVar `json:"db_name"`
SSLMode *schemas.SecretVar `json:"ssl_mode"`
MaxIdleConns int `json:"max_idle_conns"`
MaxOpenConns int `json:"max_open_conns"`
ConnMaxLifetime string `json:"conn_max_lifetime,omitempty"`
// ConnMaxIdleTime bounds how long an idle physical connection is kept before
// being closed. Without it, the idle cap is the only thing controlling pool
// size, so every burst above MaxIdleConns closes connections on return and
// reopens them on the next query — each reopen forks a Postgres backend.
ConnMaxIdleTime string `json:"conn_max_idle_time,omitempty"`
}
Config is the shared Postgres connection configuration used by framework stores.
type PasswordCommandConfig ¶
type PasswordCommandConfig struct {
Command string `json:"command"`
Args []string `json:"args,omitempty"`
Timeout string `json:"timeout,omitempty"`
// CacheTTL is how long a successfully resolved password is reused across new
// physical connections (Go duration string, default 60s). Set it below the
// credential's validity window; a rotation shorter than the TTL will fail
// connections until the cached value expires.
CacheTTL string `json:"cache_ttl,omitempty"`
}
PasswordCommandConfig describes a command that prints a Postgres password to stdout.