Skip to content

Make licensee's max degree of parallism configurable #641

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

Merged
merged 7 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion config/cdConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const crawlerStoreProvider = config.get('CRAWLER_STORE_PROVIDER') || 'cd(file)'
const maxRequeueAttemptCount = config.get('CRAWLER_MAX_REQUEUE_ATTEMPTS') || 5
const fetchedCacheTtlSeconds = config.get('CRAWLER_FETCHED_CACHE_TTL_SECONDS') || 60 * 60 * 8 //8 hours

function getPositiveNum(configName, defaultValue) {
const num = Number(config.get(configName))
return num > 0 ? num : defaultValue;
}

module.exports = {
provider: 'memory', // change this to redis if/when we want distributed config
searchPath: [module],
Expand Down Expand Up @@ -67,7 +72,9 @@ module.exports = {
},
gem: { githubToken },
go: { githubToken },
licensee: {},
licensee: {
processes: getPositiveNum(CRAWLER_LICENSEE_PARALLELISM,10)
},
maven: { githubToken },
npm: { githubToken },
nuget: { githubToken },
Expand Down
3 changes: 2 additions & 1 deletion providers/process/licensee.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ class LicenseeProcessor extends AbstractProcessor {
const root = request.document.location
const subfolders = await this.getFolders(root, ['/.git'])
const paths = ['', ...trimAllParents(subfolders, root)]
const { processes } = this.options
try {
const results = (
await Promise.all(paths.map(throat(10, path => this._runOnFolder(path, root, parameters))))
await Promise.all(paths.map(throat(processes, path => this._runOnFolder(path, root, parameters))))
).filter(x => x)
const licenses = uniqBy(flatten(results.map(result => result.licenses)), 'spdx_id')
const matched_files = flatten(results.map(result => result.matched_files))
Expand Down
Loading