Skip to content

Commit

Permalink
pool: add GetInstances method, that returns current instances connect…
Browse files Browse the repository at this point in the history
…ions 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.
  • Loading branch information
maksim.konovalov committed Feb 3, 2025
1 parent d8e2284 commit 2d6df0d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
### Added

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

### Changed

Expand Down
21 changes: 21 additions & 0 deletions pool/connection_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1506,3 +1506,24 @@ func isFeatureInSlice(expected iproto.Feature, actualSlice []iproto.Feature) boo
}
return false
}

// GetInstances retrieves a slice of Instance objects representing the connections in the pool.
func (p *ConnectionPool) GetInstances() []Instance {
p.endsMutex.Lock()
defer p.endsMutex.Unlock()

res := make([]Instance, 0, len(p.ends))

i := 0

for _, end := range p.ends {
res[i] = Instance{
Name: end.name,
Dialer: end.dialer,
Opts: end.opts,
}
i++
}

return res
}

0 comments on commit 2d6df0d

Please sign in to comment.