Skip to content

Commit f6bbf4b

Browse files
committed
Add package docs for pgxpool
1 parent afa8309 commit f6bbf4b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pgxpool/doc.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Package pgxpool is a connection pool for pgx.
2+
/*
3+
pgxpool implements a nearly identical interface to pgx connections.
4+
5+
Establishing a Connection
6+
7+
The primary way of establishing a connection is with `pgxpool.Connect`.
8+
9+
pool, err := pgxpool.Connect(context.Background(), os.Getenv("DATABASE_URL"))
10+
11+
The database connection string can be in URL or DSN format. PostgreSQL settings, pgx settings, and pool settings can be
12+
specified here. In addition, a config struct can be created by `ParseConfig` and modified before establishing the
13+
connection with `ConnectConfig`.
14+
15+
config, err := pgxpool.ParseConfig(os.Getenv("DATABASE_URL"))
16+
if err != nil {
17+
// ...
18+
}
19+
config.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
20+
// do something with every new connection
21+
}
22+
23+
pool, err := pgxpool.ConnectConfig(context.Background(), config)
24+
*/
25+
package pgxpool

0 commit comments

Comments
 (0)