-
Notifications
You must be signed in to change notification settings - Fork 110
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
default_lb: Enrich comments & docstrings #1062
Conversation
|
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.
Great PR!
I'd add a description for DefaultPolicyTargetComparator
because it is definitely not obvious what that is or why it is present.
I propose the following, lmk what you think:
Plan should return unique elements. It is not however obvious what it means because some nodes in the plan may have shards and some may not.
This helper structure defines equality of plan elements.
How the comparison works:
- If at least one of elements is shard-less then compare just nodes.
- If both elements have shards, then compare both nodes and shards.
Why is it implemented this way?
Driver should not attempt to send the same request to the same destination twice.
If plan element doesn't have shard specified, then a random shard will be chosen by the driver.
If the plan also contains the same node but with the shard present, and we randomly chose the same shard for the shard-less element, then we have duplication.
Example: plan is `[(Node1, Some(1)), (Node1, None)]` - if the driver uses the second element and randomly chooses shard 1, then we have a duplication.
On the other hand if the plan has a duplicate node, but with different shards, then we want to use both elements - so we can't just make the list unique by node, and so this struct was created.
d4ecc4d
to
cb6e7bc
Compare
v1.1: justified why latency awareness is not recommended. |
Wonderful, I'll include it in the PR. |
cb6e7bc
to
69358e4
Compare
v1.2: added |
The DefaultPolicy is a complex machinery. In order to grasp it fully, extensive comments are essential. Some internal functions' names were changed, to make them more better reflect the functions' semantics.
69358e4
to
17d495e
Compare
v1.2.1: clippy fixes. |
default_lb: Enrich comments & docstrings (cherry picked from commit da37348)
The DefaultPolicy is a complex machinery. In order to grasp it fully, extensive comments are essential.
Some internal functions' names were changed, to make them more better reflect the functions' semantics.
Pre-review checklist
[ ] I added relevant tests for new features and bug fixes.[ ] I have provided docstrings for the public items that I want to introduce.[ ] I have adjusted the documentation in./docs/source/
.[ ] I added appropriateFixes:
annotations to PR description.