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

Extract MappingRule from Configuration #571

Merged
merged 1 commit into from
Feb 2, 2018
Merged

Conversation

davidor
Copy link
Contributor

@davidor davidor commented Feb 2, 2018

Minor refactoring.

This PR extracts MappingRule from Configuration. There were many local methods in Configuration that were related only to mapping rules, so I think this makes sense.
Just to be clear, there are no changes in the implementation nor the test coverage.

I think that some of the code from Service should also be in this new module, but let's go step by step.

Let me know what you think @mikz . If you agree I'll add some documentation for the public methods.

@davidor davidor requested a review from mikz February 2, 2018 11:30
system_name = proxy_rule.metric_system_name or error('missing metric name of rule ' .. inspect(proxy_rule)),
delta = proxy_rule.delta
}
return mapping_rule.from_proxy_rule(proxy_rule)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be further simplified to map(mapping_rule.from_proxy_rule, proxy.proxy_rules or empty)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed 👍

return match
end

function _M.new(http_method, pattern, params, querystring_params, metric, delta)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep this method private because there is high chance the initializer will change with that many params.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Let's wait until we bring more functionality from Service.

@mikz
Copy link
Contributor

mikz commented Feb 2, 2018

@davidor definitely agree! This is a good path to split the configuration.lua. The .new(...) looks like has too many params, so maybe I'd not expose it just yet. But looks good anyway!

@davidor davidor force-pushed the extract-mapping-rule branch from 6cf6e0d to 3d7f33e Compare February 2, 2018 13:56
There were many local methods in `Configuration` that were related only
to mapping rules, so I think that this change makes sense.

I think that some of the code from `Service` should also be in this new
module, but let's go step by step.
@davidor davidor force-pushed the extract-mapping-rule branch from 3d7f33e to 029e910 Compare February 2, 2018 14:33
Copy link
Contributor

@mikz mikz left a comment

Choose a reason for hiding this comment

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

👍

@davidor davidor merged commit f8e03f1 into master Feb 2, 2018
@davidor davidor deleted the extract-mapping-rule branch February 2, 2018 14:56
@davidor davidor mentioned this pull request Feb 8, 2018
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.

2 participants