alloy

package
v0.0.0-...-8b1a3a3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectPgx

func ConnectPgx(
	ctx context.Context, instURI, user, pass, dbname string,
) (*pgxpool.Pool, func() error, error)

connectPgx establishes a connection to your database using pgxpool and the AlloyDB Go Connector (aka alloydbconn.Dialer)

The function takes an instance URI, a username, a password, and a database name. Usage looks like this:

pool, cleanup, err := connectPgx(
  context.Background(),
  "projects/myproject/locations/us-central1/clusters/mycluster/instances/myinstance",
  "postgres",
  "secretpassword",
  "mydb",
)

In addition to a *pgxpool.Pool type, the function returns a cleanup function that should be called when you're done with the database connection.

Types

This section is empty.

Jump to

Keyboard shortcuts

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