Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrEmptyUsername indicates database username is not configured. ErrEmptyUsername = errors.New("database username cannot be empty") // ErrEmptyPassword indicates database password is not configured. ErrEmptyPassword = errors.New("database password cannot be empty") // ErrEmptyDatabase indicates database name is not configured. ErrEmptyDatabase = errors.New("database name cannot be empty") // ErrInvalidPort indicates database port is out of valid range. ErrInvalidPort = errors.New("database port must be between 1 and 65535") )
View Source
var Module = fx.Module("db", fx.Provide(func(lc fx.Lifecycle) (*pgxpool.Pool, error) { var pool *pgxpool.Pool var err error lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { pool, err = NewDBPool(ctx) if err != nil { return err } return pool.Ping(ctx) }, OnStop: func(ctx context.Context) error { if pool != nil { pool.Close() } return nil }, }) return pool, err }), )
Module provides database connection pool to the fx application.
Functions ¶
Types ¶
type DBConfig ¶
type DBConfig struct {
// contains filtered or unexported fields
}
DBConfig holds database connection parameters.
func NewDBConfig ¶
NewDBConfig creates a DBConfig from the raw configuration.
func (*DBConfig) ConnectPool ¶
ConnectPool creates a new connection pool to the database with UUID support.
func (*DBConfig) ConnectionString ¶
ConnectionString returns the PostgreSQL connection string. Note: This exposes credentials. Avoid logging this value.
Click to show internal directories.
Click to hide internal directories.