-
Notifications
You must be signed in to change notification settings - Fork 929
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
enhance client's connectivity #800
Conversation
Codecov Report
@@ Coverage Diff @@
## master #800 +/- ##
==========================================
- Coverage 59.86% 59.70% -0.17%
==========================================
Files 259 259
Lines 12751 12758 +7
==========================================
- Hits 7634 7617 -17
- Misses 4163 4185 +22
- Partials 954 956 +2
Continue to review full report at Codecov.
|
remoting/getty/getty_client.go
Outdated
if client == nil || !client.isAvailable() || err != nil { | ||
return false | ||
} | ||
return true |
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.
if client == nil || !client.isAvailable() || err != nil { | |
return false | |
} | |
return true | |
return client != nil && client.isAvailable() && err == nil |
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.
I have changed the implementation to
// isAvailable returns true if the connection is available, or it can be re-established.
func (c *Client) IsAvailable() bool {
_, _, err := c.selectSession(c.addr)
return err == nil
}
since we need to re-establish the connection if possible.
selectSession function will try to get conn or create new conn with lock, If we just want to check whether the conn of the gettyRPCClientPool is healthy, we can add a flag to reduce the use of locks through atomic operations。 |
LGTM |
remoting/getty/getty_client.go
Outdated
_, _, err := c.selectSession(c.addr) | ||
return err == nil |
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.
_, _, err := c.selectSession(c.addr) | |
return err == nil | |
c, _, err := c.selectSession(c.addr) | |
return c!=nil && err == nil |
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.
add this defensive check, pls. check again.
enhance client's connectivity
What this PR does:
when the server is down by accident, we need a mechanism to detect this situation quickly, so that the health check router will not route the request to the problematic provider.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: