Skip to content

Conversation

@tystuyfzand
Copy link
Contributor

This PR rewrites the Closest function to add a MaxDeviation field, which allows a configurable maximum distance from the closest server to be used. This will prevent issues when there's a close (<50km) server, and then the next two closest are 500km away.

Changes

  • Adds MaxDeviation (maxDeviation in yaml) which defaults to 50km
  • Changes the default behavior to only return one server instead of a rotating list of three
  • Reverts to caching all items in a slice instead of a single item to maintain flexibility, but keeps a "fast path" to bypass the random selection/weighting code.
  • Removes localServer checks which could cause issues with countries that only have one server, or servers that are nowhere near the user. For example, if a server is in Vancouver, BC in Canada, and a user from Toronto wants to get a mirror, it would prefer and return the Vancouver mirror instead of a closer Chicago or New York one. This is resolved by using one server and the MaxDeviation fields.

- Provides better documentation on the topChoices field
- Changes default to only return the best server instead of top 3
- Avoids distant servers (>50km by default) from the top choice when topChoices is enabled, while still keeping similar servers (same location, etc)
- Reverts localized servers due to issues with large countries and limited server selection
- Prepare code for unit tests
- Mock unit tests in ideal cases
- Changes geolocation to a provider for use of either API or Mocking
- Add server tests for testing closest/choices
- Adds test for deviation checking
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.

1 participant