MCPcopy Index your code
hub / github.com/dropbox/godropbox / newBaseConnectionPool

Function newBaseConnectionPool

net2/base_connection_pool.go:38–70  ·  view source on GitHub ↗

This returns a connection pool where all connections are connected to the same (network, address)

(
	options ConnectionOptions,
	createPool func(rp.Options) rp.ResourcePool)

Source from the content-addressed store, hash-verified

36// This returns a connection pool where all connections are connected
37// to the same (network, address)
38func 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)

Callers 2

NewSimpleConnectionPoolFunction · 0.85
NewMultiConnectionPoolFunction · 0.85

Calls 2

parseResourceLocationFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected