-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DSN options to enable SQL queries on follower nodes #136
Conversation
client/conn.go
Outdated
// choose a random follower node | ||
if cfg.UseFollower && len(peers.Servers) > 1 { | ||
for { | ||
rand.Seed(time.Now().UnixNano()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's inappropriate for client SDK to modify the golang runtime global random source seed.
I thought using client package global randSource
is better, already initialized with rand.New(rand.NewSource(time.Now().UnixNano()))
.
client/conn.go
Outdated
if cfg.UseFollower && len(peers.Servers) > 1 { | ||
for { | ||
rand.Seed(time.Now().UnixNano()) | ||
node := peers.Servers[rand.Intn(len(peers.Servers))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, this rand.Intn
can be replaced with randSource.Intn
client/conn.go
Outdated
|
||
func (c *conn) stopAckWorkers() { | ||
if c.leader != nil { | ||
close(c.leader.ackCh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be replaced with c.leader.stopAckWorkers()
client/conn.go
Outdated
close(c.leader.ackCh) | ||
} | ||
if c.follower != nil { | ||
close(c.follower.ackCh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, c.follower.stopAckWorkers()
client/conn.go
Outdated
rand.Seed(time.Now().UnixNano()) | ||
node := peers.Servers[rand.Intn(len(peers.Servers))] | ||
if node != peers.Leader { | ||
c.pFollowerCaller = rpc.NewPersistentCaller(node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing CloseStream
for c.pFollowerCaller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, approve.
No description provided.