Skip to content

Commit

Permalink
Use local Random instance, and seed it
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanbergen committed May 1, 2015
1 parent 816230d commit 14fd328
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sarama

import (
"math/rand"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -119,7 +118,7 @@ func NewClient(addrs []string, conf *Config) (Client, error) {
coordinators: make(map[string]int32),
}

for _, index := range rand.Perm(len(addrs)) {
for _, index := range Random.Perm(len(addrs)) {
client.seedBrokers = append(client.seedBrokers, NewBroker(addrs[index]))
}

Expand Down
4 changes: 4 additions & 0 deletions sarama.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ package sarama
import (
"io/ioutil"
"log"
"math/rand"
"time"
)

// Logger is the instance of a StdLogger interface that Sarama writes connection
// management events to. By default it is set to discard all log messages via ioutil.Discard,
// but you can set it to redirect wherever you want.
var Logger StdLogger = log.New(ioutil.Discard, "[Sarama] ", log.LstdFlags)

var Random = rand.New(rand.NewSource(time.Now().UnixNano()))

// StdLogger is used to log error messages.
type StdLogger interface {
Print(v ...interface{})
Expand Down

0 comments on commit 14fd328

Please sign in to comment.