tonic-xds: Implement subchannel state machine#2587
Draft
gu0keno0 wants to merge 2 commits intohyperium:masterfrom
Draft
tonic-xds: Implement subchannel state machine#2587gu0keno0 wants to merge 2 commits intohyperium:masterfrom
gu0keno0 wants to merge 2 commits intohyperium:masterfrom
Conversation
Collaborator
Author
|
WIP, will replace stream with futures, because streammap's poll is O(N). |
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.
Implement the type-statemachine for load balancer subchannels. This is preparing for implementing the actual load balancer.
Ref: #2444
Motivation
A real world xDS load-balancer needs to deal with outlier detection and reconnects. Therefore, subchannels managed by load balancer needs to implement a state machine. This PR implements it via type-states.
In the next PR, the load balancer tower layer will drive the state transitions in its poll_ready() implementation. This way, we get full control and visibility in to the managed channels. Therefore, we opens up the flexibility of implementing different LB strategies (e.g. sticky, round-robin, etc), compared to the hardcoded P2C stategy offered by tower::balance that we are currently using.
Solution
Define new type for each state, state transition is implemented by consuming the type for the source state. ConnectingChannel and EjectedChannel needs to be implemented as Streams so that load balancer can use StreamMap to poll them to advance their state transitions.