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.
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
Add
concurrency
option #69Add
concurrency
option #69Changes from 4 commits
7ac71f6
2f55ac3
1c884c9
4f4b875
7a95e94
f861103
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why did you create a new var to make
options.concurrency
default to(os.cpus().length || 1) * 2
?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 added the new variable to make it explicit in reading what the value meant, do you think it's unnecessary? I think having it like this also makes it easier to find the default value. I could make it so no variable is added, or changing it such that the default value is abstracted to a variable and pass it with
{concurrency: options.concurrency || defaultConcurrency}
instead, my only concern was the readability of the code.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 think what @hugomrdias is saying (and giving you a hint) is that you can simply the code. For example, you may leverage object spread to have default options being mixed in with the ones the user supplies.
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.
Hmm, not sure what you mean with object spread, since this code change operates with only one of the options. The other options are handled in other functions.
I could default it like:
module.exports = (source, destination, options = {concurrency: (os.cpus().length || 1 * 2}) => [...]
...which also makes the default value easy to find. I'm not sure if this would work. Do you think that would be 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.
You are right in the sense that each option is currently being handled in each function, so perhaps lets keep the consistency.
Still, we may simplify with:
Also, by renaming the variable to
concurrency
fromconcurrencyDegree
, you may use it directly when passing it topAll
.Other than that, the PR looks good. However, I suggest adding a simple test (smoke test) to see if the concurrency is being respected.