Simplify if prioritization and add :route_metric_fun option #332
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 set of commits mostly moves code and types around to clean up the route
metric calculation logic. Luckily, there's high test coverage here as almost all
of this is side effect free logic. Plus some code got to be deleted.
The main new feature is to add a key,
:route_metric_fun
that lets youcompletely replace the built-in metric calculation that's now in the
default_metric.ex
module. The previous intention was to let users specify aprioritization list or set weights. That was never completely implemented, and
with the benefit of hindsight, looks complicated compared to implementing the
code yourself. A non-general purpose implementation is probably as simple as
pattern matching the interface name and internet status and then returning a
metric number.
This is backwards incompatible since prioritization table customization has been
deleted. I don't know anyone using this, but if they are, I hope that the new
:route_metric_fun
option is a simpler solution to what they're trying toaccomplish.