Use struct instead of map[string]string for connection params
This commit is contained in:
+4
-7
@@ -2,25 +2,22 @@ package pgx
|
||||
|
||||
type ConnectionPool struct {
|
||||
connectionChannel chan *Connection
|
||||
options map[string]string // options used when establishing connection
|
||||
parameters ConnectionParameters // options used when establishing connection
|
||||
MaxConnections int
|
||||
}
|
||||
|
||||
// options: options used by Connect
|
||||
// MaxConnections: max simultaneous connections to use (currently all are immediately connected)
|
||||
func NewConnectionPool(options map[string]string, MaxConnections int) (p *ConnectionPool, err error) {
|
||||
func NewConnectionPool(parameters ConnectionParameters, MaxConnections int) (p *ConnectionPool, err error) {
|
||||
p = new(ConnectionPool)
|
||||
p.connectionChannel = make(chan *Connection, MaxConnections)
|
||||
p.MaxConnections = MaxConnections
|
||||
|
||||
p.options = make(map[string]string)
|
||||
for k, v := range options {
|
||||
p.options[k] = v
|
||||
}
|
||||
p.parameters = parameters
|
||||
|
||||
for i := 0; i < p.MaxConnections; i++ {
|
||||
var c *Connection
|
||||
c, err = Connect(options)
|
||||
c, err = Connect(p.parameters)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user