Add DSN options to enable SQL queries on follower nodes#136
Merged
leventeliu merged 6 commits intodevelopfrom Dec 14, 2018
Merged
Add DSN options to enable SQL queries on follower nodes#136leventeliu merged 6 commits intodevelopfrom
leventeliu merged 6 commits intodevelopfrom
Conversation
xq262144
reviewed
Dec 13, 2018
client/conn.go
Outdated
| // choose a random follower node | ||
| if cfg.UseFollower && len(peers.Servers) > 1 { | ||
| for { | ||
| rand.Seed(time.Now().UnixNano()) |
Contributor
There was a problem hiding this comment.
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))] |
Contributor
There was a problem hiding this comment.
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) |
Contributor
There was a problem hiding this comment.
Should be replaced with c.leader.stopAckWorkers()
client/conn.go
Outdated
| close(c.leader.ackCh) | ||
| } | ||
| if c.follower != nil { | ||
| close(c.follower.ackCh) |
Contributor
There was a problem hiding this comment.
Likewise, c.follower.stopAckWorkers()
xq262144
reviewed
Dec 13, 2018
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) |
Contributor
There was a problem hiding this comment.
Missing CloseStream for c.pFollowerCaller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.