Skip to content

Commit bb4d014

Browse files
author
maksim.konovalov
committedFeb 3, 2025
pool: add GetInstances method, that returns current instances connections state
The GetConnections method has been added, which is necessary to monitor the current state of the pool. This should help implement dynamic tracking of tarantool topology changes.
1 parent d8e2284 commit bb4d014

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

Diff for: ‎pool/connection_pool.go

+21
Original file line numberDiff line numberDiff line change
@@ -1506,3 +1506,24 @@ func isFeatureInSlice(expected iproto.Feature, actualSlice []iproto.Feature) boo
15061506
}
15071507
return false
15081508
}
1509+
1510+
// GetInstances retrieves a slice of Instance objects representing the connections in the pool.
1511+
func (p *ConnectionPool) GetInstances() []Instance {
1512+
p.endsMutex.Lock()
1513+
defer p.endsMutex.Unlock()
1514+
1515+
res := make([]Instance, 0, len(p.ends))
1516+
1517+
i := 0
1518+
1519+
for _, end := range p.ends {
1520+
res[i] = Instance{
1521+
Name: end.name,
1522+
Dialer: end.dialer,
1523+
Opts: end.opts,
1524+
}
1525+
i++
1526+
}
1527+
1528+
return res
1529+
}

0 commit comments

Comments
 (0)