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

Should client use its own source for randomness? #40

Open
nmiyake opened this issue May 17, 2019 · 0 comments
Open

Should client use its own source for randomness? #40

nmiyake opened this issue May 17, 2019 · 0 comments

Comments

@nmiyake
Copy link
Contributor

nmiyake commented May 17, 2019

Currently, the Do function of httpclient.clientImpl uses rand.Intn(len(uris)) to determine the offset that should be used for the URI.

This code uses the global source for randomness, so unless the client application explicitly seeds the global random source, the sequence of offsets that this code chooses will always be the same.

This is not necessarily an issue in and of itself, but does seem somewhat counter-intuitive. Possible approaches:

  • Document that sequence of offsets chosen will be deterministic unless global source of randomness is seeded
  • Store *rand.Rand as part of the client and seed it on construction (and optionally expose a way to disable seeding it/specifying a seed manually if there is a desire to control the sequence)
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

No branches or pull requests

1 participant