This returns a connection pool where all connections are connected to the same (network, address)
( options ConnectionOptions, createPool func(rp.Options) rp.ResourcePool)
| 36 | // This returns a connection pool where all connections are connected |
| 37 | // to the same (network, address) |
| 38 | func newBaseConnectionPool( |
| 39 | options ConnectionOptions, |
| 40 | createPool func(rp.Options) rp.ResourcePool) ConnectionPool { |
| 41 | |
| 42 | dial := options.Dial |
| 43 | if dial == nil { |
| 44 | dial = defaultDialFunc |
| 45 | } |
| 46 | |
| 47 | openFunc := func(loc string) (interface{}, error) { |
| 48 | network, address := parseResourceLocation(loc) |
| 49 | return dial(network, address) |
| 50 | } |
| 51 | |
| 52 | closeFunc := func(handle interface{}) error { |
| 53 | return handle.(net.Conn).Close() |
| 54 | } |
| 55 | |
| 56 | poolOptions := rp.Options{ |
| 57 | MaxActiveHandles: options.MaxActiveConnections, |
| 58 | MaxIdleHandles: options.MaxIdleConnections, |
| 59 | MaxIdleTime: options.MaxIdleTime, |
| 60 | OpenMaxConcurrency: options.DialMaxConcurrency, |
| 61 | Open: openFunc, |
| 62 | Close: closeFunc, |
| 63 | NowFunc: options.NowFunc, |
| 64 | } |
| 65 | |
| 66 | return &connectionPoolImpl{ |
| 67 | options: options, |
| 68 | pool: createPool(poolOptions), |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // This returns a connection pool where all connections are connected |
| 73 | // to the same (network, address) |
no test coverage detected