Skip to content
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

[CHANGED] Randomize Leafnode remote URLs and add option to disable #2156

Merged
merged 1 commit into from Apr 26, 2021

Conversation

variadico
Copy link
Contributor

@variadico variadico commented Apr 22, 2021

Currently, leafnode remote URLs are kept in order when parsed. This change randomizes the order of URLs by default and adds an option to disable this behavior, returning you to the way it was before.

leafnodes {
  remotes = [
    {
      dont_randomize: true
      url: [
        "nats-leaf://host1:7422"
        "nats-leaf://host2:7422"
        "nats-leaf://host3:7422"
        "nats-leaf://host4:7422"
      ]
      account: fizzbuzz
      credentials: "./fizzbuzz.creds"
    }
  ]
}

Resolves #2153

/cc @nats-io/core

server/opts.go Outdated Show resolved Hide resolved
server/opts_test.go Outdated Show resolved Hide resolved
@matthiashanel
Copy link
Contributor

@variadico @kozlovic , wondering if we should enable this by default and provide an option to turn it off. In part because this is the right thing to do, Why make it harder by having to enable the better behavior.

@ripienaar
Copy link
Contributor

Agree. Should be default.

@kozlovic
Copy link
Member

Yes, sorry I missed that too. Since I saw the discussion on Slack and issue reported by Don R., I assumed that this was the direction we would take. @variadico The flag would have to be a negative, like "NoSuffle" or something like that.

@variadico variadico changed the title Add ability to shuffle leafnode remote urls Randomize leafnode route URLs and add option to disable Apr 23, 2021
@kozlovic kozlovic changed the title Randomize leafnode route URLs and add option to disable [CHANGED] Randomize Leafnode remote URLs and add option to disable Apr 23, 2021
@variadico
Copy link
Contributor Author

All right. Got some updates.

  • Moved rand.Shuffle to validateLeafNode
  • Made rand.Shuffle the default behavior
  • Changed the name "shuffle" to "random" to match the term the NATS client uses (any thoughts on this?)
  • Updated the parsing code
  • Added new tests

@variadico variadico force-pushed the leaf-shuffle branch 2 times, most recently from 94684ca to a20fc83 Compare April 23, 2021 19:04
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kozlovic kozlovic merged commit 0ba3aaf into master Apr 26, 2021
@kozlovic kozlovic deleted the leaf-shuffle branch April 26, 2021 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NATS LeafNode remote URLs : Config to shuffle, on by default
5 participants