Code golf

Pointed out by: @dadgar
This commit is contained in:
Sean Chittenden 2016-06-21 14:26:01 -07:00
parent df4fe2e502
commit 8bdb38d016
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
2 changed files with 4 additions and 10 deletions

View File

@ -1248,11 +1248,8 @@ func (c *Client) setupConsulSyncer() error {
// Nomad servers are available within
// datacenterQueryLimit, the next heartbeat will pick
// a new set of servers so it's okay.
nearestDC := dcs[0]
dcs = dcs[1:]
shuffleStrings(dcs)
otherDCs := dcs[0:lib.MinInt(len(dcs), datacenterQueryLimit)]
dcs = append([]string{nearestDC}, otherDCs...)
shuffleStrings(dcs[1:])
dcs = dcs[0:lib.MinInt(len(dcs), datacenterQueryLimit)]
}
// Forward RPCs to our region

View File

@ -469,11 +469,8 @@ func (s *Server) setupBootstrapHandler() error {
// are necessary, this Nomad Server will eventually
// walk all datacenter until it finds enough hosts to
// form a quorum.
nearestDC := dcs[0]
dcs = dcs[1:]
shuffleStrings(dcs)
otherDCs := dcs[0:lib.MinInt(len(dcs), datacenterQueryLimit)]
dcs = append([]string{nearestDC}, otherDCs...)
shuffleStrings(dcs[1:])
dcs = dcs[0:lib.MinInt(len(dcs), datacenterQueryLimit)]
}
nomadServerServiceName := s.config.ConsulConfig.ServerServiceName