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 bb4d014
Showing 1 changed file with 21 additions and 0 deletions.
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 bb4d014

Please sign in to comment.