BackendSelection improvements for least connections#269
Closed
Object905 wants to merge 3 commits into
Closed
Conversation
Author
|
Closing, since
|
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.
Hi. I wanted to implement my own backend selection (basically least connections), but faced some inconvenience and issues.
To address Inconvenience:
Moved
BackendIterbound intoBackendSelection::Iter.It was only used with this bound everywhere anyway, even docs says that Iter should be BackendIter.
Can't see any reason why it's like that. Tested against rust 1.72 to verify that it satisfies msrv.
It doesn't break any existing code, just makes bound
S::Iter: BackendIterredundant.Issues:
selectorfield inLoadBalanceris private, but I needed to access it to share some handle that will be used to notify selector of pending upstream requests.It's possible to achieve this by other means (either global state, but then it's hard to share code, or more api churn and changing public interfaces, which I don't want to do here).
When backends are updated new instance of
BackendSelectionis created and replaced, but to keep handle from previous selector I had to resort to global state. So I addedprevious: Option<Arc<Self>>argument that will be passed in LoadBalancer::update, so it's possible to keep provided handle or some other state. This is somewhat breaking change.Related Issue: #144
Maybe later after my experiments will make a PR for least connections.