...

Source file src/github.com/jackc/pgx/v4/pgxpool/doc.go

Documentation: github.com/jackc/pgx/v4/pgxpool

     1  // Package pgxpool is a concurrency-safe 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
    26  

View as plain text