-
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
balancer: add ExitIdle optional interface #4673
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a3d227d
balancer: add ExitIdle optional interface
dfawley df5236d
comments
dfawley cf03c76
add test; fix compile error
dfawley bc3b87f
move type assertion
dfawley 3f9acd4
rebase
dfawley 23abf8b
fix comments; ExitIdler
dfawley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,24 +75,29 @@ func Get(name string) Builder { | |
return nil | ||
} | ||
|
||
// SubConn represents a gRPC sub connection. | ||
// Each sub connection contains a list of addresses. gRPC will | ||
// try to connect to them (in sequence), and stop trying the | ||
// remainder once one connection is successful. | ||
// A SubConn represents a single connection to a gRPC backend service. | ||
// | ||
// Each SubConn contains a list of addresses. | ||
// | ||
// All SubConns start in IDLE, and will not try to connect. To trigger the | ||
// connecting, Balancers must call Connect. | ||
// | ||
// gRPC will try to connect to the addresses in sequence, and stop trying the | ||
// remainder once the first connection is successful. If an attempt to connect | ||
// to all addresses encounters an error, the SubConn will automatically attempt | ||
// to reconnect after an increasing backoff period. | ||
// | ||
// The reconnect backoff will be applied on the list, not a single address. | ||
// For example, try_on_all_addresses -> backoff -> try_on_all_addresses. | ||
// | ||
// All SubConns start in IDLE, and will not try to connect. To trigger | ||
// the connecting, Balancers must call Connect. | ||
// When the connection encounters an error, it will reconnect immediately. | ||
// When the connection becomes IDLE, it will not reconnect unless Connect is | ||
// called. | ||
// Once established, if a connection is lost, the SubConn will transition to | ||
// IDLE. When the connection becomes IDLE, it will not reconnect unless Connect | ||
// is called. | ||
// | ||
// This interface is to be implemented by gRPC. Users should not need a | ||
// brand new implementation of this interface. For the situations like | ||
// testing, the new implementation should embed this interface. This allows | ||
// gRPC to add new methods to this interface. | ||
// This interface is to be implemented by gRPC. Users should not need their own | ||
// implementation of this interface. For situations like testing, any | ||
// implementations should embed this interface. This allows gRPC to add new | ||
// methods to this interface. | ||
type SubConn interface { | ||
// UpdateAddresses updates the addresses used in this SubConn. | ||
// gRPC checks if currently-connected address is still in the new list. | ||
|
@@ -326,6 +331,20 @@ type Balancer interface { | |
Close() | ||
} | ||
|
||
// ExitIdle is an optional interface for balancers to implement. If | ||
// implemented, ExitIdle will be called when ClientConn.Connect is called, if | ||
// the ClientConn is idle. If unimplemented, ClientConn.Connect will cause | ||
// all SubConns to connect. | ||
// | ||
// Notice: it will be required for all balancers to implement this in a future | ||
// release. | ||
type ExitIdle interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
// ExitIdle instructs the LB policy to reconnect to backends / exit the | ||
// IDLE state, if appropriate and possible. Note that SubConns that enter | ||
// the IDLE state will not reconnect until SubConn.Connect is called. | ||
ExitIdle() | ||
} | ||
|
||
// SubConnState describes the state of a SubConn. | ||
type SubConnState struct { | ||
// ConnectivityState is the connectivity state of the SubConn. | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -488,3 +488,5 @@ func (lb *lbBalancer) Close() { | |
} | ||
lb.cc.close() | ||
} | ||
|
||
func (lb *lbBalancer) ExitIdle() {} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Will not automatically attempt?
It will transition to IDLE, right?
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.
Yes, I'm not sure what I was thinking.