@@ -23,7 +23,7 @@ import (
23
23
)
24
24
25
25
var (
26
- ErrEmptyAddrs = errors .New ("addrs (first argument) should not be empty" )
26
+ ErrEmptyDialers = errors .New ("dialers (second argument) should not be empty" )
27
27
ErrWrongCheckTimeout = errors .New ("wrong check timeout, must be greater than 0" )
28
28
ErrNoConnection = errors .New ("no active connections" )
29
29
ErrTooManyArgs = errors .New ("too many arguments" )
@@ -94,8 +94,8 @@ Main features:
94
94
- Automatic master discovery by mode parameter.
95
95
*/
96
96
type ConnectionPool struct {
97
- addrs map [string ]* endpoint
98
- addrsMutex sync.RWMutex
97
+ ends map [string ]* endpoint
98
+ endsMutex sync.RWMutex
99
99
100
100
connOpts tarantool.Opts
101
101
opts Opts
@@ -112,7 +112,8 @@ type ConnectionPool struct {
112
112
var _ Pooler = (* ConnectionPool )(nil )
113
113
114
114
type endpoint struct {
115
- addr string
115
+ id string
116
+ dialer tarantool.Dialer
116
117
notify chan tarantool.ConnEvent
117
118
conn * tarantool.Connection
118
119
role Role
@@ -124,9 +125,10 @@ type endpoint struct {
124
125
closeErr error
125
126
}
126
127
127
- func newEndpoint (addr string ) * endpoint {
128
+ func newEndpoint (id string , dialer tarantool. Dialer ) * endpoint {
128
129
return & endpoint {
129
- addr : addr ,
130
+ id : id ,
131
+ dialer : dialer ,
130
132
notify : make (chan tarantool.ConnEvent , 100 ),
131
133
conn : nil ,
132
134
role : UnknownRole ,
@@ -137,24 +139,24 @@ func newEndpoint(addr string) *endpoint {
137
139
}
138
140
}
139
141
140
- // ConnectWithOpts creates pool for instances with addresses addrs
141
- // with options opts .
142
- func ConnectWithOpts (ctx context.Context , addrs [] string ,
142
+ // ConnectWithOpts creates pool for instances with specified dialers and options opts.
143
+ // Each dialer corresponds to a certain id by which they will be distinguished .
144
+ func ConnectWithOpts (ctx context.Context , dialers map [ string ]tarantool. Dialer ,
143
145
connOpts tarantool.Opts , opts Opts ) (* ConnectionPool , error ) {
144
- if len (addrs ) == 0 {
145
- return nil , ErrEmptyAddrs
146
+ if len (dialers ) == 0 {
147
+ return nil , ErrEmptyDialers
146
148
}
147
149
if opts .CheckTimeout <= 0 {
148
150
return nil , ErrWrongCheckTimeout
149
151
}
150
152
151
- size := len (addrs )
153
+ size := len (dialers )
152
154
rwPool := newRoundRobinStrategy (size )
153
155
roPool := newRoundRobinStrategy (size )
154
156
anyPool := newRoundRobinStrategy (size )
155
157
156
158
connPool := & ConnectionPool {
157
- addrs : make (map [string ]* endpoint ),
159
+ ends : make (map [string ]* endpoint ),
158
160
connOpts : connOpts .Clone (),
159
161
opts : opts ,
160
162
state : unknownState ,
@@ -164,11 +166,7 @@ func ConnectWithOpts(ctx context.Context, addrs []string,
164
166
anyPool : anyPool ,
165
167
}
166
168
167
- for _ , addr := range addrs {
168
- connPool .addrs [addr ] = nil
169
- }
170
-
171
- somebodyAlive , ctxCanceled := connPool .fillPools (ctx )
169
+ somebodyAlive , ctxCanceled := connPool .fillPools (ctx , dialers )
172
170
if ! somebodyAlive {
173
171
connPool .state .set (closedState )
174
172
if ctxCanceled {
@@ -179,7 +177,7 @@ func ConnectWithOpts(ctx context.Context, addrs []string,
179
177
180
178
connPool .state .set (connectedState )
181
179
182
- for _ , s := range connPool .addrs {
180
+ for _ , s := range connPool .ends {
183
181
endpointCtx , cancel := context .WithCancel (context .Background ())
184
182
s .cancel = cancel
185
183
go connPool .controller (endpointCtx , s )
@@ -188,17 +186,18 @@ func ConnectWithOpts(ctx context.Context, addrs []string,
188
186
return connPool , nil
189
187
}
190
188
191
- // ConnectWithOpts creates pool for instances with addresses addrs.
189
+ // Connect creates pool for instances with specified dialers.
190
+ // Each dialer corresponds to a certain id by which they will be distinguished.
192
191
//
193
192
// It is useless to set up tarantool.Opts.Reconnect value for a connection.
194
193
// The connection pool has its own reconnection logic. See
195
194
// Opts.CheckTimeout description.
196
- func Connect (ctx context.Context , addrs [] string ,
195
+ func Connect (ctx context.Context , dialers map [ string ]tarantool. Dialer ,
197
196
connOpts tarantool.Opts ) (* ConnectionPool , error ) {
198
197
opts := Opts {
199
198
CheckTimeout : 1 * time .Second ,
200
199
}
201
- return ConnectWithOpts (ctx , addrs , connOpts , opts )
200
+ return ConnectWithOpts (ctx , dialers , connOpts , opts )
202
201
}
203
202
204
203
// ConnectedNow gets connected status of pool.
@@ -235,32 +234,32 @@ func (p *ConnectionPool) ConfiguredTimeout(mode Mode) (time.Duration, error) {
235
234
return conn .ConfiguredTimeout (), nil
236
235
}
237
236
238
- // Add adds a new endpoint with the address into the pool. This function
237
+ // Add adds a new endpoint with the id into the pool. This function
239
238
// adds the endpoint only after successful connection.
240
- func (p * ConnectionPool ) Add (ctx context.Context , addr string ) error {
241
- e := newEndpoint (addr )
239
+ func (p * ConnectionPool ) Add (ctx context.Context , id string , dialer tarantool. Dialer ) error {
240
+ e := newEndpoint (id , dialer )
242
241
243
- p .addrsMutex .Lock ()
242
+ p .endsMutex .Lock ()
244
243
// Ensure that Close()/CloseGraceful() not in progress/done.
245
244
if p .state .get () != connectedState {
246
- p .addrsMutex .Unlock ()
245
+ p .endsMutex .Unlock ()
247
246
return ErrClosed
248
247
}
249
- if _ , ok := p .addrs [ addr ]; ok {
250
- p .addrsMutex .Unlock ()
248
+ if _ , ok := p .ends [ id ]; ok {
249
+ p .endsMutex .Unlock ()
251
250
return ErrExists
252
251
}
253
252
254
253
endpointCtx , cancel := context .WithCancel (context .Background ())
255
254
e .cancel = cancel
256
255
257
- p .addrs [ addr ] = e
258
- p .addrsMutex .Unlock ()
256
+ p .ends [ id ] = e
257
+ p .endsMutex .Unlock ()
259
258
260
259
if err := p .tryConnect (ctx , e ); err != nil {
261
- p .addrsMutex .Lock ()
262
- delete (p .addrs , addr )
263
- p .addrsMutex .Unlock ()
260
+ p .endsMutex .Lock ()
261
+ delete (p .ends , id )
262
+ p .endsMutex .Unlock ()
264
263
e .cancel ()
265
264
close (e .closed )
266
265
return err
@@ -270,13 +269,13 @@ func (p *ConnectionPool) Add(ctx context.Context, addr string) error {
270
269
return nil
271
270
}
272
271
273
- // Remove removes an endpoint with the address from the pool. The call
272
+ // Remove removes an endpoint with the id from the pool. The call
274
273
// closes an active connection gracefully.
275
- func (p * ConnectionPool ) Remove (addr string ) error {
276
- p .addrsMutex .Lock ()
277
- endpoint , ok := p .addrs [ addr ]
274
+ func (p * ConnectionPool ) Remove (id string ) error {
275
+ p .endsMutex .Lock ()
276
+ endpoint , ok := p .ends [ id ]
278
277
if ! ok {
279
- p .addrsMutex .Unlock ()
278
+ p .endsMutex .Unlock ()
280
279
return errors .New ("endpoint not exist" )
281
280
}
282
281
@@ -290,20 +289,20 @@ func (p *ConnectionPool) Remove(addr string) error {
290
289
close (endpoint .shutdown )
291
290
}
292
291
293
- delete (p .addrs , addr )
294
- p .addrsMutex .Unlock ()
292
+ delete (p .ends , id )
293
+ p .endsMutex .Unlock ()
295
294
296
295
<- endpoint .closed
297
296
return nil
298
297
}
299
298
300
299
func (p * ConnectionPool ) waitClose () []error {
301
- p .addrsMutex .RLock ()
302
- endpoints := make ([]* endpoint , 0 , len (p .addrs ))
303
- for _ , e := range p .addrs {
300
+ p .endsMutex .RLock ()
301
+ endpoints := make ([]* endpoint , 0 , len (p .ends ))
302
+ for _ , e := range p .ends {
304
303
endpoints = append (endpoints , e )
305
304
}
306
- p .addrsMutex .RUnlock ()
305
+ p .endsMutex .RUnlock ()
307
306
308
307
errs := make ([]error , 0 , len (endpoints ))
309
308
for _ , e := range endpoints {
@@ -319,12 +318,12 @@ func (p *ConnectionPool) waitClose() []error {
319
318
func (p * ConnectionPool ) Close () []error {
320
319
if p .state .cas (connectedState , closedState ) ||
321
320
p .state .cas (shutdownState , closedState ) {
322
- p .addrsMutex .RLock ()
323
- for _ , s := range p .addrs {
321
+ p .endsMutex .RLock ()
322
+ for _ , s := range p .ends {
324
323
s .cancel ()
325
324
close (s .close )
326
325
}
327
- p .addrsMutex .RUnlock ()
326
+ p .endsMutex .RUnlock ()
328
327
}
329
328
330
329
return p .waitClose ()
@@ -334,47 +333,31 @@ func (p *ConnectionPool) Close() []error {
334
333
// for all requests to complete.
335
334
func (p * ConnectionPool ) CloseGraceful () []error {
336
335
if p .state .cas (connectedState , shutdownState ) {
337
- p .addrsMutex .RLock ()
338
- for _ , s := range p .addrs {
336
+ p .endsMutex .RLock ()
337
+ for _ , s := range p .ends {
339
338
s .cancel ()
340
339
close (s .shutdown )
341
340
}
342
- p .addrsMutex .RUnlock ()
341
+ p .endsMutex .RUnlock ()
343
342
}
344
343
345
344
return p .waitClose ()
346
345
}
347
346
348
- // GetAddrs gets addresses of connections in pool.
349
- func (p * ConnectionPool ) GetAddrs () []string {
350
- p .addrsMutex .RLock ()
351
- defer p .addrsMutex .RUnlock ()
352
-
353
- cpy := make ([]string , len (p .addrs ))
354
-
355
- i := 0
356
- for addr := range p .addrs {
357
- cpy [i ] = addr
358
- i ++
359
- }
360
-
361
- return cpy
362
- }
363
-
364
- // GetPoolInfo gets information of connections (connected status, ro/rw role).
365
- func (p * ConnectionPool ) GetPoolInfo () map [string ]* ConnectionInfo {
347
+ // GetInfo gets information of connections (connected status, ro/rw role).
348
+ func (p * ConnectionPool ) GetInfo () map [string ]* ConnectionInfo {
366
349
info := make (map [string ]* ConnectionInfo )
367
350
368
- p .addrsMutex .RLock ()
369
- defer p .addrsMutex .RUnlock ()
351
+ p .endsMutex .RLock ()
352
+ defer p .endsMutex .RUnlock ()
370
353
p .poolsMutex .RLock ()
371
354
defer p .poolsMutex .RUnlock ()
372
355
373
356
if p .state .get () != connectedState {
374
357
return info
375
358
}
376
359
377
- for addr := range p .addrs {
360
+ for addr := range p .ends {
378
361
conn , role := p .getConnectionFromPool (addr )
379
362
if conn != nil {
380
363
info [addr ] = & ConnectionInfo {ConnectedNow : conn .ConnectedNow (), ConnRole : role }
@@ -932,16 +915,33 @@ func (p *ConnectionPool) NewPrepared(expr string, userMode Mode) (*tarantool.Pre
932
915
// Since 1.10.0
933
916
func (p * ConnectionPool ) NewWatcher (key string ,
934
917
callback tarantool.WatchCallback , mode Mode ) (tarantool.Watcher , error ) {
935
- watchersRequired := false
936
- for _ , feature := range p .connOpts .RequiredProtocolInfo .Features {
937
- if iproto .IPROTO_FEATURE_WATCHERS == feature {
938
- watchersRequired = true
918
+
919
+ rr := p .anyPool
920
+ if mode == RW {
921
+ rr = p .rwPool
922
+ } else if mode == RO {
923
+ rr = p .roPool
924
+ }
925
+
926
+ conns := rr .GetConnections ()
927
+
928
+ watchersRequired := true
929
+ for _ , conn := range conns {
930
+ watchersRequired = false
931
+ for _ , feature := range conn .ServerProtocolInfo ().Features {
932
+ if iproto .IPROTO_FEATURE_WATCHERS == feature {
933
+ watchersRequired = true
934
+ break
935
+ }
936
+ }
937
+ if ! watchersRequired {
939
938
break
940
939
}
941
940
}
941
+
942
942
if ! watchersRequired {
943
943
return nil , errors .New ("the feature IPROTO_FEATURE_WATCHERS must " +
944
- "be required by connection options to create a watcher" )
944
+ "be required by any connection to create a watcher" )
945
945
}
946
946
947
947
watcher := & poolWatcher {
@@ -955,14 +955,6 @@ func (p *ConnectionPool) NewWatcher(key string,
955
955
956
956
watcher .container .add (watcher )
957
957
958
- rr := p .anyPool
959
- if mode == RW {
960
- rr = p .rwPool
961
- } else if mode == RO {
962
- rr = p .roPool
963
- }
964
-
965
- conns := rr .GetConnections ()
966
958
for _ , conn := range conns {
967
959
if err := watcher .watch (conn ); err != nil {
968
960
conn .Close ()
@@ -1030,22 +1022,22 @@ func (p *ConnectionPool) getConnectionRole(conn *tarantool.Connection) (Role, er
1030
1022
return UnknownRole , nil
1031
1023
}
1032
1024
1033
- func (p * ConnectionPool ) getConnectionFromPool (addr string ) (* tarantool.Connection , Role ) {
1034
- if conn := p .rwPool .GetConnByAddr ( addr ); conn != nil {
1025
+ func (p * ConnectionPool ) getConnectionFromPool (id string ) (* tarantool.Connection , Role ) {
1026
+ if conn := p .rwPool .GetConnById ( id ); conn != nil {
1035
1027
return conn , MasterRole
1036
1028
}
1037
1029
1038
- if conn := p .roPool .GetConnByAddr ( addr ); conn != nil {
1030
+ if conn := p .roPool .GetConnById ( id ); conn != nil {
1039
1031
return conn , ReplicaRole
1040
1032
}
1041
1033
1042
- return p .anyPool .GetConnByAddr ( addr ), UnknownRole
1034
+ return p .anyPool .GetConnById ( id ), UnknownRole
1043
1035
}
1044
1036
1045
- func (p * ConnectionPool ) deleteConnection (addr string ) {
1046
- if conn := p .anyPool .DeleteConnByAddr ( addr ); conn != nil {
1047
- if conn := p .rwPool .DeleteConnByAddr ( addr ); conn == nil {
1048
- p .roPool .DeleteConnByAddr ( addr )
1037
+ func (p * ConnectionPool ) deleteConnection (id string ) {
1038
+ if conn := p .anyPool .DeleteConnById ( id ); conn != nil {
1039
+ if conn := p .rwPool .DeleteConnById ( id ); conn == nil {
1040
+ p .roPool .DeleteConnById ( id )
1049
1041
}
1050
1042
// The internal connection deinitialization.
1051
1043
p .watcherContainer .mutex .RLock ()
@@ -1058,7 +1050,7 @@ func (p *ConnectionPool) deleteConnection(addr string) {
1058
1050
}
1059
1051
}
1060
1052
1061
- func (p * ConnectionPool ) addConnection (addr string ,
1053
+ func (p * ConnectionPool ) addConnection (id string ,
1062
1054
conn * tarantool.Connection , role Role ) error {
1063
1055
// The internal connection initialization.
1064
1056
p .watcherContainer .mutex .RLock ()
@@ -1087,17 +1079,17 @@ func (p *ConnectionPool) addConnection(addr string,
1087
1079
for _ , watcher := range watched {
1088
1080
watcher .unwatch (conn )
1089
1081
}
1090
- log .Printf ("tarantool: failed initialize watchers for %s: %s" , addr , err )
1082
+ log .Printf ("tarantool: failed initialize watchers for %s: %s" , id , err )
1091
1083
return err
1092
1084
}
1093
1085
1094
- p .anyPool .AddConn (addr , conn )
1086
+ p .anyPool .AddConn (id , conn )
1095
1087
1096
1088
switch role {
1097
1089
case MasterRole :
1098
- p .rwPool .AddConn (addr , conn )
1090
+ p .rwPool .AddConn (id , conn )
1099
1091
case ReplicaRole :
1100
- p .roPool .AddConn (addr , conn )
1092
+ p .roPool .AddConn (id , conn )
1101
1093
}
1102
1094
return nil
1103
1095
}
@@ -1130,35 +1122,35 @@ func (p *ConnectionPool) handlerDeactivated(conn *tarantool.Connection,
1130
1122
}
1131
1123
}
1132
1124
1133
- func (p * ConnectionPool ) deactivateConnection (addr string ,
1125
+ func (p * ConnectionPool ) deactivateConnection (id string ,
1134
1126
conn * tarantool.Connection , role Role ) {
1135
- p .deleteConnection (addr )
1127
+ p .deleteConnection (id )
1136
1128
conn .Close ()
1137
1129
p .handlerDeactivated (conn , role )
1138
1130
}
1139
1131
1140
1132
func (p * ConnectionPool ) deactivateConnections () {
1141
- for address , endpoint := range p .addrs {
1133
+ for id , endpoint := range p .ends {
1142
1134
if endpoint != nil && endpoint .conn != nil {
1143
- p .deactivateConnection (address , endpoint .conn , endpoint .role )
1135
+ p .deactivateConnection (id , endpoint .conn , endpoint .role )
1144
1136
}
1145
1137
}
1146
1138
}
1147
1139
1148
1140
func (p * ConnectionPool ) processConnection (conn * tarantool.Connection ,
1149
- addr string , end * endpoint ) bool {
1141
+ id string , end * endpoint ) bool {
1150
1142
role , err := p .getConnectionRole (conn )
1151
1143
if err != nil {
1152
1144
conn .Close ()
1153
- log .Printf ("tarantool: storing connection to %s failed: %s\n " , addr , err )
1145
+ log .Printf ("tarantool: storing connection %s failed: %s\n " , id , err )
1154
1146
return false
1155
1147
}
1156
1148
1157
1149
if ! p .handlerDiscovered (conn , role ) {
1158
1150
conn .Close ()
1159
1151
return false
1160
1152
}
1161
- if p .addConnection (addr , conn , role ) != nil {
1153
+ if p .addConnection (id , conn , role ) != nil {
1162
1154
conn .Close ()
1163
1155
p .handlerDeactivated (conn , role )
1164
1156
return false
@@ -1169,34 +1161,35 @@ func (p *ConnectionPool) processConnection(conn *tarantool.Connection,
1169
1161
return true
1170
1162
}
1171
1163
1172
- func (p * ConnectionPool ) fillPools (ctx context.Context ) (bool , bool ) {
1164
+ func (p * ConnectionPool ) fillPools (
1165
+ ctx context.Context ,
1166
+ dialers map [string ]tarantool.Dialer ) (bool , bool ) {
1173
1167
somebodyAlive := false
1174
1168
ctxCanceled := false
1175
1169
1176
- // It is called before controller() goroutines so we don't expect
1170
+ // It is called before controller() goroutines, so we don't expect
1177
1171
// concurrency issues here.
1178
- for addr := range p .addrs {
1179
- end := newEndpoint (addr )
1180
- p .addrs [addr ] = end
1181
-
1172
+ for id , dialer := range dialers {
1173
+ end := newEndpoint (id , dialer )
1174
+ p .ends [id ] = end
1182
1175
connOpts := p .connOpts
1183
1176
connOpts .Notify = end .notify
1184
- conn , err := tarantool .Connect (ctx , addr , connOpts )
1177
+ conn , err := tarantool .Connect (ctx , dialer , connOpts )
1185
1178
if err != nil {
1186
- log .Printf ("tarantool: connect to %s failed: %s\n " , addr , err .Error ())
1179
+ log .Printf ("tarantool: connect to %s failed: %s\n " , dialer . GetAddr () , err .Error ())
1187
1180
select {
1188
1181
case <- ctx .Done ():
1189
1182
ctxCanceled = true
1190
1183
1191
- p .addrs [ addr ] = nil
1184
+ p .ends [ id ] = nil
1192
1185
log .Printf ("tarantool: operation was canceled" )
1193
1186
1194
1187
p .deactivateConnections ()
1195
1188
1196
1189
return false , ctxCanceled
1197
1190
default :
1198
1191
}
1199
- } else if p .processConnection (conn , addr , end ) {
1192
+ } else if p .processConnection (conn , id , end ) {
1200
1193
somebodyAlive = true
1201
1194
}
1202
1195
}
@@ -1214,7 +1207,7 @@ func (p *ConnectionPool) updateConnection(e *endpoint) {
1214
1207
1215
1208
if role , err := p .getConnectionRole (e .conn ); err == nil {
1216
1209
if e .role != role {
1217
- p .deleteConnection (e .addr )
1210
+ p .deleteConnection (e .id )
1218
1211
p .poolsMutex .Unlock ()
1219
1212
1220
1213
p .handlerDeactivated (e .conn , e .role )
@@ -1237,7 +1230,7 @@ func (p *ConnectionPool) updateConnection(e *endpoint) {
1237
1230
return
1238
1231
}
1239
1232
1240
- if p .addConnection (e .addr , e .conn , role ) != nil {
1233
+ if p .addConnection (e .id , e .conn , role ) != nil {
1241
1234
p .poolsMutex .Unlock ()
1242
1235
1243
1236
e .conn .Close ()
@@ -1251,7 +1244,7 @@ func (p *ConnectionPool) updateConnection(e *endpoint) {
1251
1244
p .poolsMutex .Unlock ()
1252
1245
return
1253
1246
} else {
1254
- p .deleteConnection (e .addr )
1247
+ p .deleteConnection (e .id )
1255
1248
p .poolsMutex .Unlock ()
1256
1249
1257
1250
e .conn .Close ()
@@ -1275,14 +1268,15 @@ func (p *ConnectionPool) tryConnect(ctx context.Context, e *endpoint) error {
1275
1268
1276
1269
connOpts := p .connOpts
1277
1270
connOpts .Notify = e .notify
1278
- conn , err := tarantool .Connect (ctx , e .addr , connOpts )
1271
+ conn , err := tarantool .Connect (ctx , e .dialer , connOpts )
1279
1272
if err == nil {
1280
1273
role , err := p .getConnectionRole (conn )
1281
1274
p .poolsMutex .Unlock ()
1282
1275
1283
1276
if err != nil {
1284
1277
conn .Close ()
1285
- log .Printf ("tarantool: storing connection to %s failed: %s\n " , e .addr , err )
1278
+ log .Printf ("tarantool: storing connection to %s failed: %s\n " ,
1279
+ e .dialer .GetAddr (), err )
1286
1280
return err
1287
1281
}
1288
1282
@@ -1300,7 +1294,7 @@ func (p *ConnectionPool) tryConnect(ctx context.Context, e *endpoint) error {
1300
1294
return ErrClosed
1301
1295
}
1302
1296
1303
- if err = p .addConnection (e .addr , conn , role ); err != nil {
1297
+ if err = p .addConnection (e .id , conn , role ); err != nil {
1304
1298
p .poolsMutex .Unlock ()
1305
1299
conn .Close ()
1306
1300
p .handlerDeactivated (conn , role )
@@ -1322,7 +1316,7 @@ func (p *ConnectionPool) reconnect(ctx context.Context, e *endpoint) {
1322
1316
return
1323
1317
}
1324
1318
1325
- p .deleteConnection (e .addr )
1319
+ p .deleteConnection (e .id )
1326
1320
p .poolsMutex .Unlock ()
1327
1321
1328
1322
p .handlerDeactivated (e .conn , e .role )
@@ -1358,7 +1352,7 @@ func (p *ConnectionPool) controller(ctx context.Context, e *endpoint) {
1358
1352
case <- e .close :
1359
1353
if e .conn != nil {
1360
1354
p .poolsMutex .Lock ()
1361
- p .deleteConnection (e .addr )
1355
+ p .deleteConnection (e .id )
1362
1356
p .poolsMutex .Unlock ()
1363
1357
1364
1358
if ! shutdown {
@@ -1380,7 +1374,7 @@ func (p *ConnectionPool) controller(ctx context.Context, e *endpoint) {
1380
1374
shutdown = true
1381
1375
if e .conn != nil {
1382
1376
p .poolsMutex .Lock ()
1383
- p .deleteConnection (e .addr )
1377
+ p .deleteConnection (e .id )
1384
1378
p .poolsMutex .Unlock ()
1385
1379
1386
1380
// We need to catch s.close in the current goroutine, so
@@ -1402,7 +1396,7 @@ func (p *ConnectionPool) controller(ctx context.Context, e *endpoint) {
1402
1396
if e .conn != nil && e .conn .ClosedNow () {
1403
1397
p .poolsMutex .Lock ()
1404
1398
if p .state .get () == connectedState {
1405
- p .deleteConnection (e .addr )
1399
+ p .deleteConnection (e .id )
1406
1400
p .poolsMutex .Unlock ()
1407
1401
p .handlerDeactivated (e .conn , e .role )
1408
1402
e .conn = nil
0 commit comments