Don't call time.Now() unnecessarily

pull/567/merge
John Shahid 2014-05-23 14:21:14 -04:00
parent afe2352278
commit 67c30bc63f
1 changed files with 5 additions and 1 deletions

View File

@ -305,7 +305,11 @@ func (self *ShardData) Query(querySpec *parser.QuerySpec, response chan *p.Respo
log.Error(message)
return
}
randServerIndex := int(time.Now().UnixNano() % int64(healthyCount))
randServerIndex := 0
if healthyCount > 1 {
randServerIndex = int(time.Now().UnixNano() % int64(healthyCount))
}
server := healthyServers[randServerIndex]
log.Debug("Querying server %d for shard %d", server.GetId(), self.Id())
request := self.createRequest(querySpec)