Rotate dns results - #421
Open
PizieDust wants to merge 1 commit into
Open
Conversation
Member
|
"but doesn't randomize the entire list" <- would you mind to explain what "the entire list" is? |
hannesm
reviewed
Jul 20, 2026
Comment on lines
+3477
to
+3491
| let rotate_list lst = | ||
| match lst with | ||
| | [] | [_] -> lst | ||
| | _ -> | ||
| let k = Random.int (List.length lst) in | ||
| let rec split k acc = function | ||
| | [] -> List.rev acc | ||
| | x :: xs as l -> | ||
| if k = 0 then | ||
| l @ (List.rev acc) | ||
| else | ||
| split (k - 1) (x :: acc) xs | ||
| in | ||
| split k [] lst | ||
| in |
Member
There was a problem hiding this comment.
I don't quite understand what this "rotate_list" implements. Is this based on some common literature about how to shuffle a list?
Contributor
Author
There was a problem hiding this comment.
No it doesn't really shuffle the list. Just changes where the list starts. I think for DNS round robin it's better to rotate the list, since clients always connect to the first IP in the list. By rotating the list we can be sure all IP's get a fair chance of being picked.
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.
This PR implements shuffling for IP addresses but doesn't randomize the entire list.
cc @reynir @hannesm @dinosaure