-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Worker): Allows subset of workers to reduce processing (LLC-9)
- Loading branch information
1 parent
8d0e78b
commit 6a8e084
Showing
4 changed files
with
86 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import logger from 'lib/logger'; | ||
import { | ||
STATEMENT_QUERYBUILDERCACHE_QUEUE, | ||
STATEMENT_EXTRACT_PERSONAS_QUEUE, | ||
STATEMENT_FORWARDING_QUEUE, | ||
} from 'lib/constants/statements'; | ||
|
||
/** | ||
* allowable Worker Queues | ||
* | ||
* @type {string[]} | ||
*/ | ||
const allowableWorkerQueues = [ | ||
STATEMENT_QUERYBUILDERCACHE_QUEUE, | ||
STATEMENT_EXTRACT_PERSONAS_QUEUE, | ||
STATEMENT_FORWARDING_QUEUE, | ||
]; | ||
|
||
/** | ||
* @param {string | undefined} allowedWorkerQueuesString | ||
* @return {string[]} | ||
* @throws {Error} | ||
*/ | ||
const getAllowedWorkerQueues = (allowedWorkerQueuesString) => { | ||
if (allowedWorkerQueuesString === undefined) { | ||
return allowableWorkerQueues; | ||
} | ||
|
||
if (allowedWorkerQueuesString === '') { | ||
return []; | ||
} | ||
|
||
return allowedWorkerQueuesString.split(',').reduce( | ||
(acc, queueString) => { | ||
if (allowableWorkerQueues.includes(queueString)) { | ||
return acc.concat([queueString]); | ||
} | ||
logger.warn(`"${queueString}" is ignored as an allowed worker queue. Allowable worker queues are ${allowableWorkerQueues.map(q => `"${q}"`).join(', ')}`); | ||
return acc; | ||
}, | ||
[], | ||
); | ||
}; | ||
|
||
/** | ||
* @type {string[]} | ||
*/ | ||
const allowedWorkerQueues = getAllowedWorkerQueues(process.env.ALLOWED_WORKER_QUEUES); | ||
|
||
/* eslint-disable import/prefer-default-export*/ | ||
export const isAllowedWorkerQueue = queueName => allowedWorkerQueues.includes(queueName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters