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

Simplify if prioritization and add :route_metric_fun option #332

Merged
merged 5 commits into from
Aug 19, 2021

Conversation

fhunleth
Copy link
Member

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 you
completely replace the built-in metric calculation that's now in the
default_metric.ex module. The previous intention was to let users specify a
prioritization 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 to
accomplish.

  • Move the connection_status to top level
  • Separate interface name utilities out of classification
  • Move route metric calculation and remove custom priorities
  • Dialyzer doesn't need to ignore warnings
  • Support complete replacement of metric calculation

It's used so many places and makes more sense here now.
Currently, interface naming utilities and prioritization are mixed in
the same module. Interface prioritization is going to get more
complicate, so separating out unrelated code seems like it should make
it more easy to understand.
This add docs and sets up the possibility of completely overriding route
metric prioritization. Going through the default calculation is
nontrivial due to a lack of information. It's way easier to just replace
the whole function with exactly what you want and that's the goal here.
As a result, the ability to dynamically set interface prioritization
order goes away. That's nice sense it deletes a bit of code that
probably wasn't used and was too inflexible anyway.

This is a backwards incompatible change for anyone setting an interface
prioritization table. If you don't use that, then this PR just moves
code around.
This adds a new key, `:route_metric_fun`, that let's users get rid of
the default metric calculator and use their own. The default calculator
probably works for most users, but once you find yourself outside of
what works with the defaults, it's probably easiest to code a solution
that exactly works with your setup rather than try to encourage the
default calculator to work for you.
@fhunleth fhunleth merged commit d380400 into main Aug 19, 2021
@fhunleth fhunleth deleted the classification-weights branch August 19, 2021 14:30
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.

None yet

2 participants