cleanup: remove more copies of min/max from helper

This commit is contained in:
Seth Hoenig 2022-08-24 09:56:15 -05:00
parent ea1802ffa0
commit bff6c88683
4 changed files with 3 additions and 19 deletions

View File

@ -2823,7 +2823,7 @@ func (c *Client) consulDiscoveryImpl() error {
// datacenterQueryLimit, the next heartbeat will pick // datacenterQueryLimit, the next heartbeat will pick
// a new set of servers so it's okay. // a new set of servers so it's okay.
shuffleStrings(dcs[1:]) shuffleStrings(dcs[1:])
dcs = dcs[0:helper.MinInt(len(dcs), datacenterQueryLimit)] dcs = dcs[0:helper.Min(len(dcs), datacenterQueryLimit)]
} }
// Query for servers in this client's region only // Query for servers in this client's region only

View File

@ -1,16 +0,0 @@
// These functions are coming from consul/lib/math.go
package helper
func MaxInt(a, b int) int {
if a > b {
return a
}
return b
}
func MinInt(a, b int) int {
if a > b {
return b
}
return a
}

View File

@ -544,7 +544,7 @@ func (b *BlockedEvals) unblock(computedClass, quota string, index uint64) {
// because any node could potentially be feasible. // because any node could potentially be feasible.
numEscaped := len(b.escaped) numEscaped := len(b.escaped)
numQuotaLimit := 0 numQuotaLimit := 0
unblocked := make(map[*structs.Evaluation]string, helper.MaxInt(numEscaped, 4)) unblocked := make(map[*structs.Evaluation]string, helper.Max(numEscaped, 4))
if numEscaped != 0 && computedClass != "" { if numEscaped != 0 && computedClass != "" {
for id, wrapped := range b.escaped { for id, wrapped := range b.escaped {

View File

@ -961,7 +961,7 @@ func (s *Server) setupBootstrapHandler() error {
// walk all datacenter until it finds enough hosts to // walk all datacenter until it finds enough hosts to
// form a quorum. // form a quorum.
shuffleStrings(dcs[1:]) shuffleStrings(dcs[1:])
dcs = dcs[0:helper.MinInt(len(dcs), datacenterQueryLimit)] dcs = dcs[0:helper.Min(len(dcs), datacenterQueryLimit)]
} }
nomadServerServiceName := s.config.ConsulConfig.ServerServiceName nomadServerServiceName := s.config.ConsulConfig.ServerServiceName