scaffolder-backend: make concurrentTasksLimit configurable via static config
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
The `concurrentTasksLimit` option can now be configured via static configuration as well. Setting it to 0 will now also disable the task worker.
|
||||
+9
@@ -28,5 +28,14 @@ export interface Config {
|
||||
* The commit message used when new components are created.
|
||||
*/
|
||||
defaultCommitMessage?: string;
|
||||
|
||||
/**
|
||||
* Sets the number of concurrent tasks that can be run at any given time on the TaskWorker.
|
||||
*
|
||||
* Defaults to 10.
|
||||
*
|
||||
* Set to 0 to disable task workers altogether.
|
||||
*/
|
||||
concurrentTasksLimit?: number;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -231,13 +231,15 @@ export async function createRouter(
|
||||
catalogClient,
|
||||
actions,
|
||||
taskWorkers,
|
||||
concurrentTasksLimit,
|
||||
scheduler,
|
||||
additionalTemplateFilters,
|
||||
additionalTemplateGlobals,
|
||||
permissions,
|
||||
permissionRules,
|
||||
} = options;
|
||||
const concurrentTasksLimit =
|
||||
options.concurrentTasksLimit ??
|
||||
options.config.getOptionalNumber('scaffolder.concurrentTasksLimit');
|
||||
|
||||
const logger = parentLogger.child({ plugin: 'scaffolder' });
|
||||
|
||||
@@ -275,19 +277,21 @@ export async function createRouter(
|
||||
const actionRegistry = new TemplateActionRegistry();
|
||||
|
||||
const workers = [];
|
||||
for (let i = 0; i < (taskWorkers || 1); i++) {
|
||||
const worker = await TaskWorker.create({
|
||||
taskBroker,
|
||||
actionRegistry,
|
||||
integrations,
|
||||
logger,
|
||||
workingDirectory,
|
||||
additionalTemplateFilters,
|
||||
additionalTemplateGlobals,
|
||||
concurrentTasksLimit,
|
||||
permissions,
|
||||
});
|
||||
workers.push(worker);
|
||||
if (concurrentTasksLimit !== 0) {
|
||||
for (let i = 0; i < (taskWorkers || 1); i++) {
|
||||
const worker = await TaskWorker.create({
|
||||
taskBroker,
|
||||
actionRegistry,
|
||||
integrations,
|
||||
logger,
|
||||
workingDirectory,
|
||||
additionalTemplateFilters,
|
||||
additionalTemplateGlobals,
|
||||
concurrentTasksLimit,
|
||||
permissions,
|
||||
});
|
||||
workers.push(worker);
|
||||
}
|
||||
}
|
||||
|
||||
const actionsToRegister = Array.isArray(actions)
|
||||
|
||||
Reference in New Issue
Block a user