Documentation
¶
Overview ¶
Package postgres provides common code for working with the Postgres database in the context of PGQS service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConfig = errors.New("invalid configuration")
ErrConfig is the error returned when the configuration is invalid.
Functions ¶
func MapNotificationToLogFields ¶
func MapNotificationToLogFields(n *Notifications) []logger.Field
MapNotificationToLogFields maps the notification to a slice of logger fields.
Types ¶
type Config ¶
type Config struct {
User string `name:"user" flag:"-"`
//nolint:gosec // G117: credential loaded from env via configs.Resolve; never logged verbatim (MapToLogFields).
Pass string `name:"pass" flag:"-"`
Database string `name:"database" flag:"-"`
Host string `name:"host" default:"127.0.0.1" flag:"-"`
SSLMode string `name:"ssl_mode" default:"disable" flag:"-"`
Port int `name:"port" default:"5432" flag:"-"`
}
Config represents the configuration for the Postgres database.
func ResolveConfig ¶
ResolveConfig resolves the configuration for the Postgres database. Expecting only env variables with prefix "PG_". Returns the configuration and an error if the configuration is invalid.
func (*Config) MapToLogFields ¶
MapToLogFields maps the configuration to a slice of logger fields.
type DBPool ¶
type Dialect ¶
type Dialect = goqu.DialectWrapper
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func NewListener ¶
NewListener creates a new Listener for channel on conn. notificationBuffer is the capacity of Notifications(); values less than 1 are treated as 1.
func NewListenerFromPool ¶
func NewListenerFromPool(ctx context.Context, pool *DBPool, channel string, notificationBuffer int) (*Listener, error)
NewListenerFromPool acquires a connection from pool and returns a Listener for channel. notificationBuffer is the capacity of Notifications(); values less than 1 are treated as 1.
func (*Listener) Notifications ¶
func (l *Listener) Notifications() <-chan *Notifications
Notifications returns a channel to receive database notifications from the listener asynchronously.
type Notifications ¶
type Notifications = pgconn.Notification