-
Notifications
You must be signed in to change notification settings - Fork 439
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
feat: enable peer discovery modules by default #209
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I preferred being explicit but this is good as well. Mind adding tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanshaw if we're going to change the defaults I think we should change them in the ./src/config.js
file.
With this change the config will throw an error if someone doesn't supply the config for the peerDiscovery, tests would be great here to catch that. We should set default values here:
Lines 66 to 72 in 6905f1b
config.modules.peerDiscovery.forEach((discovery) => { | |
// If it's a function, validate we have configs for it | |
if (typeof discovery === 'function') { | |
Joi.reach(schema, 'config.peerDiscovery').keys({ | |
[discovery.tag]: Joi.object().required() | |
}) | |
} |
@jacobheun I don't think that peer discovery module validation code is working properly 😟 . I just found problems with the test for it and fixed them and it fails now: I'm not changing any defaults, just allowing modules that don't require any config or have already been configured to still be registered and started. IMHO it's unnecessary to require a developer to pass a preconfigured module instance and also have to set a config value with I don't think we should validate config for each of the discovery modules - that's outside of the scope of this module. We can't know what all the config options are and keep that info up to date. All we could meaningfully do would be to validate a boolean |
@jacobheun how about now? Is better 😛 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanshaw yesssss! This looks great, and thank you for cleaning up the config, so much easier to read. I agree that defaulting to enabled will be easier to users.
Failed ci looks to be CI having a bad day, not an issue with tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Mind rebasing master onto this branch and wait for CI before the merge?
This PR will enable any provided peer discovery modules by default if no configuration for the module is supplied/needed. As before, modules can be explicitly disabled or enabled by passing config. This also enables pre-configured modules (instances) to be passed and enabled without them having to have a `tag` and an unused config section. License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
Configuration for the peer discovery modules is now optional so this does not need to be validated. This also cleans up the config module to reduce repetition. License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
558858c
to
8c83e07
Compare
This PR will enable any provided peer discovery modules by default if no configuration for the module is supplied/needed.
As before, modules can be explicitly disabled or enabled by passing config.
This enables pre-configured modules (instances) to be passed and enabled without them having to have a
tag
and an unused config section.