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

added config validation #82

Merged
merged 5 commits into from
Jan 12, 2017
Merged

added config validation #82

merged 5 commits into from
Jan 12, 2017

Conversation

trescube
Copy link
Contributor

@trescube trescube commented Jan 5, 2017

We should discuss this. The tradition has been to put configValidation in the main entry point so the module can't even be loaded if the configuration is invalid, that doesn't work the same way in this module since pelias config can be passed to the individual create functions. We should probably go with dependency injection so to the create function gets only what it needs instead of hosting the entire pelias config internally.

@orangejulius
Copy link
Member

We've had a couple discussions around the interface to wof-admin-lookup. One suggestion is to encapsulate all the setup of admin lookup into one function. That would really help since the config validation logic would live there too.

@trescube trescube force-pushed the add-config-validation branch from a6b808d to ad8258e Compare January 12, 2017 16:26
@trescube trescube self-assigned this Jan 12, 2017
@trescube trescube added this to the API Improvements milestone Jan 12, 2017
"tap-dot": "^1.0.1",
"tape": "^4.2.2",
"semantic-release": "^6.3.2"
"tape": "^4.2.2"
Copy link
Member

Choose a reason for hiding this comment

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

tape should be a 'dev dependency', easily fixed with:

npm rm tape --save;
npm i tape@latest --save-dev

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is bad formatting on github's part, dependencies are slotted as correct.

var _ = require('lodash');

let maxConcurrentReqs;
Copy link
Member

Choose a reason for hiding this comment

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

why is this module scope?

I only see one reference to it at the bottom

There is also another variable of another scope with the same name:

this.maxConcurrentReqs

is that intended?


function RemotePIPResolver(url, config) {
function RemotePIPResolver(url) {
// prepend url with 'http://' if not already
this.normalizedUrl = _.startsWith(url, 'http://') ? url : 'http://' + url;
Copy link
Member

Choose a reason for hiding this comment

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

what happens in the case of a URL using the https:// protocol?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is existing code.

@@ -3,6 +3,8 @@
var logger = require('pelias-logger').get('wof-admin-lookup');
var createPIPService = require('pelias-wof-pip-service').create;

let datapath;
Copy link
Member

Choose a reason for hiding this comment

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

what is the advantage of using module scope here over dependency injection via function args?

module.exports = {
createLookupStream: createLookupStream
module.exports = (options) => {
maxConcurrentReqs = _.get(options, 'maxConcurrentReqs', 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

having these be global variables in this module seems a bit odd to me since you can make many different streams with different vars and the global will always reflect the last ones.

@trescube trescube merged commit d16e89a into master Jan 12, 2017
@trescube trescube deleted the add-config-validation branch January 12, 2017 20:29
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.

4 participants