-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
ClientConn: Introduce GetStatus method to get the latest connection error #2055
Conversation
@@ -877,6 +887,9 @@ func (cc *ClientConn) removeAddrConn(ac *addrConn, err error) { | |||
return | |||
} | |||
delete(cc.conns, ac) | |||
if len(cc.conns) == 0 { | |||
cc.blockingpicker.updateConnectionError(errors.New("no backends returned by resolver")) |
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.
What if the balancer wanted to remove the last addrConn from cc? It will also be zero in that case.
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.
Isn't this that code path?
if cc.GetState() != connectivity.TransientFailure { | ||
return nil | ||
} | ||
return status.Errorf(codes.Unavailable, "latest connection error: %v", cc.blockingpicker.connectionError()) |
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.
What's the advantage of using status error here?
What other error codes will we return?
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 mirrors the Java API. That one returns a status directly, but I thought "error" would be more idiomatic for us.
Closing for now until I get a chance to revisit. |
Fixes #2031
This may be just a proof of concept, but I think we will need something like this. A few things I noticed:
GetState() == TransientFailure
and doing theGetStatus()
call, so maybe it's fine?