Skip to content

Commit 2d6df0d

Browse files
author
maksim.konovalov
committed
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 2d6df0d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
1111
### Added
1212

1313
- Extend box with replication information (#427).
14+
- The GetConnections method has been added,
15+
which is necessary to monitor the current state of the pool (#428).
1416

1517
### Changed
1618

pool/connection_pool.go

Lines changed: 21 additions & 0 deletions
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)