Rename ConnectionPoolOptions to ConnPoolConfig
This commit is contained in:
@@ -139,7 +139,7 @@ changing transcoders).
|
|||||||
### Logging
|
### Logging
|
||||||
|
|
||||||
Pgx defines the pgx.Logger interface. A value that satisfies this interface
|
Pgx defines the pgx.Logger interface. A value that satisfies this interface
|
||||||
used as part of ConnectionOptions or ConnectionPoolOptions to enable logging
|
used as part of ConnectionOptions or ConnPoolConfig to enable logging
|
||||||
of pgx activities.
|
of pgx activities.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|||||||
+1
-1
@@ -635,7 +635,7 @@ func BenchmarkTimestampTzBinary(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkConnPool(b *testing.B) {
|
func BenchmarkConnPool(b *testing.B) {
|
||||||
options := pgx.ConnectionPoolOptions{MaxConnections: 5}
|
options := pgx.ConnPoolConfig{MaxConnections: 5}
|
||||||
pool, err := pgx.NewConnPool(*defaultConnConfig, options)
|
pool, err := pgx.NewConnPool(*defaultConnConfig, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Unable to create connection pool: %v", err)
|
b.Fatalf("Unable to create connection pool: %v", err)
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConnectionPoolOptions struct {
|
type ConnPoolConfig struct {
|
||||||
MaxConnections int // max simultaneous connections to use
|
MaxConnections int // max simultaneous connections to use
|
||||||
AfterConnect func(*Conn) error
|
AfterConnect func(*Conn) error
|
||||||
Logger Logger
|
Logger Logger
|
||||||
@@ -29,7 +29,7 @@ type ConnPoolStat struct {
|
|||||||
|
|
||||||
// NewConnPool creates a new ConnPool. config are passed through to
|
// NewConnPool creates a new ConnPool. config are passed through to
|
||||||
// Connect directly.
|
// Connect directly.
|
||||||
func NewConnPool(config ConnConfig, options ConnectionPoolOptions) (p *ConnPool, err error) {
|
func NewConnPool(config ConnConfig, options ConnPoolConfig) (p *ConnPool, err error) {
|
||||||
p = new(ConnPool)
|
p = new(ConnPool)
|
||||||
p.config = config
|
p.config = config
|
||||||
p.maxConnections = options.MaxConnections
|
p.maxConnections = options.MaxConnections
|
||||||
|
|||||||
+3
-3
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func createConnPool(t *testing.T, maxConnections int) *pgx.ConnPool {
|
func createConnPool(t *testing.T, maxConnections int) *pgx.ConnPool {
|
||||||
options := pgx.ConnectionPoolOptions{MaxConnections: maxConnections}
|
options := pgx.ConnPoolConfig{MaxConnections: maxConnections}
|
||||||
pool, err := pgx.NewConnPool(*defaultConnConfig, options)
|
pool, err := pgx.NewConnPool(*defaultConnConfig, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to create connection pool: %v", err)
|
t.Fatalf("Unable to create connection pool: %v", err)
|
||||||
@@ -24,7 +24,7 @@ func TestNewConnPool(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
options := pgx.ConnectionPoolOptions{MaxConnections: 2, AfterConnect: afterConnect}
|
options := pgx.ConnPoolConfig{MaxConnections: 2, AfterConnect: afterConnect}
|
||||||
pool, err := pgx.NewConnPool(*defaultConnConfig, options)
|
pool, err := pgx.NewConnPool(*defaultConnConfig, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unable to establish connection pool")
|
t.Fatal("Unable to establish connection pool")
|
||||||
@@ -43,7 +43,7 @@ func TestNewConnPool(t *testing.T) {
|
|||||||
return errAfterConnect
|
return errAfterConnect
|
||||||
}
|
}
|
||||||
|
|
||||||
options = pgx.ConnectionPoolOptions{MaxConnections: 2, AfterConnect: afterConnect}
|
options = pgx.ConnPoolConfig{MaxConnections: 2, AfterConnect: afterConnect}
|
||||||
pool, err = pgx.NewConnPool(*defaultConnConfig, options)
|
pool, err = pgx.NewConnPool(*defaultConnConfig, options)
|
||||||
if err != errAfterConnect {
|
if err != errAfterConnect {
|
||||||
t.Errorf("Expected errAfterConnect but received unexpected: %v", err)
|
t.Errorf("Expected errAfterConnect but received unexpected: %v", err)
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ func main() {
|
|||||||
User: "jack",
|
User: "jack",
|
||||||
Password: "jack",
|
Password: "jack",
|
||||||
Database: "url_shortener"}
|
Database: "url_shortener"}
|
||||||
poolOptions := pgx.ConnectionPoolOptions{MaxConnections: 5, AfterConnect: afterConnect}
|
poolOptions := pgx.ConnPoolConfig{MaxConnections: 5, AfterConnect: afterConnect}
|
||||||
pool, err = pgx.NewConnectionPool(connectionOptions, poolOptions)
|
pool, err = pgx.NewConnectionPool(connectionOptions, poolOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Unable to create connection pool: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Unable to create connection pool: %v\n", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user