psql

package
v0.19.1069 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllModels

func AllModels() []any

declare all models in the correct order they should be migrated.

func AsPSQL

func AsPSQL(f any) any

func AsPSQLReplica added in v0.19.916

func AsPSQLReplica(f any) any

func FetchGcpCloudSqlPassword added in v0.19.866

func FetchGcpCloudSqlPassword(ctx context.Context, _ database) (string, error)

FetchGcpCloudSqlPassword fetches a GCP OAuth2 access token for use as the password in Cloud SQL IAM database authentication. The token is obtained via the default credential chain (Workload Identity on GKE).

func FetchIamTokenPassword

func FetchIamTokenPassword(ctx context.Context, cfg database) (string, error)

FetchIamTokenPassword fetches an iam token which can be used as a password using the default aws credentials provider

func New

func NewPSQLMigrator

func NewPSQLMigrator(p PSQLParams, lc fx.Lifecycle) *migrations.Migrator

func NewPrimaryListenerConn added in v0.19.1006

func NewPrimaryListenerConn(ctx context.Context, cfg *internal.Config) (*pgx.Conn, error)

NewPrimaryListenerConn opens a single dedicated, non-pooled connection to the PRIMARY database, suitable for LISTEN/NOTIFY. The caller owns the connection and must Close it.

This deliberately bypasses the pgxpool: a LISTEN binds to a session and pins a connection for its lifetime, which is the wrong thing to take from a shared pool. Because RDS IAM auth tokens rotate (~15m) and pooled connections are recycled on a 5m lifetime, callers should periodically tear this connection down and re-open via this function rather than holding it open indefinitely — each reopen re-runs the IAM token fetch below.

func NewReplica added in v0.19.916

func NewReplica(v *validator.Validate,
	l zapgorm2.Logger,
	metricsWriter metrics.Writer,
	lc fx.Lifecycle,
	cfg *internal.Config,
	qc *querycollector.Collector,
) (*gorm.DB, error)

NewReplica errors if DBReplicaHost is empty so callers can't silently fall back to the primary.

Types

type PSQLParams

type PSQLParams struct {
	fx.In

	Migrations   *psqlmigrations.Migrations
	MigrationsDB *gorm.DB `name:"psql"`
	DB           *gorm.DB `name:"psql"`

	L             *zap.Logger
	Cfg           *internal.Config
	MetricsWriter metrics.Writer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL