Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PostgresPingChecker ¶
PostgresPingChecker creates a health check function for the database
Types ¶
type Config ¶
type Config struct {
DSN string `` /* 142-byte string literal not displayed */
Host string `env:"HOST" envDefault:"127.0.0.1" comment:"The host to connect to"`
Port int32 `env:"PORT" envDefault:"5432" comment:"The port to connect to"`
Database string `env:"DATABASE" envDefault:"postgres" comment:"Database name"`
Username string `env:"USERNAME" envDefault:"postgres" comment:"The username to connect with"`
Password string `env:"PASSWORD" envDefault:"" comment:"The password to connect with"`
SSLMode string `env:"SSLMODE" envDefault:"disable" comment:"SSL mode (disable, allow, prefer, require, verify-ca, verify-full)"`
MaxPoolSize int `env:"MAX_POOL_SIZE" envDefault:"50" comment:"Max pool size"`
MinPoolSize int `env:"MIN_POOL_SIZE" envDefault:"10" comment:"Min pool size"`
MaxConnLifetime time.Duration `env:"MAX_CONN_LIFETIME" envDefault:"1h" comment:"Maximum connection lifetime"`
MaxConnIdleTime time.Duration `env:"MAX_CONN_IDLE_TIME" envDefault:"30m" comment:"Maximum connection idle time"`
HealthCheckPeriod time.Duration `env:"HEALTH_CHECK_PERIOD" envDefault:"1m" comment:"Health check period"`
ConnAttempts int `env:"CONN_ATTEMPTS" envDefault:"3" comment:"Connection attempts"`
ConnTimeout time.Duration `env:"CONN_TIMEOUT" envDefault:"5s" comment:"Connection timeout"`
MigrationsDir string `env:"MIGRATIONS_DIR" comment:"Migrations directory"`
}
Config defines the database configuration parameters
type Options ¶
type Options struct {
// Name is the prefix used for configuration variables
Name string
}
Options contains plugin initialization options
type Plugin ¶
type Plugin interface {
// DB returns the database connection pool
DB() *pgxpool.Pool
// RunMigration executes database migrations from the configured directory
RunMigration() error
}
Plugin represents a PostgreSQL database plugin interface
func NewTestPlugin ¶
func NewTestPlugin(ctx context.Context, cfg TestConfig) (Plugin, error)
NewTestPlugin creates a plugin instance configured for testing
type PostgresContainer ¶
type PostgresContainer interface {
GetDSN(ctx context.Context) (string, error)
Close(ctx context.Context) error
}
PostgresContainer defines interface for database container management
type TestConfig ¶
type TestConfig struct {
Config
// RunContainer indicates whether to start a test container
RunContainer bool
// ContainerImage specifies custom PostgreSQL image for test container
ContainerImage string
// ContainerName sets custom name for test container
ContainerName string
// MacConnections limits maximum number of connections
MacConnections int
}
TestConfig extends Config with additional testing-specific options
Click to show internal directories.
Click to hide internal directories.