Allow configurable number of taskworkers
Right now we are limited to one taskworker in the scaffolder backend which means you can only scaffold one thing at a time. This is a poor user experience for larger organizations where multiple users maybe scaffolding at the same time. This adds an optional configuration option to increase the number of taskworkers via the router options if you like, but defaults to 1 if not set. Signed-off-by: jrusso1020 <jrusso@brex.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': minor
|
||||
---
|
||||
|
||||
This adds a configuration option to the scaffolder plugin router, so we can allow for multiple taskworkers. Currently with only one taskworker you are limited to scaffolding one thing at a time. Set the `taskWorkers?: number` option in your scaffolder router to get more than 1 taskworker
|
||||
@@ -241,6 +241,10 @@ supertype
|
||||
talkdesk
|
||||
Talkdesk
|
||||
tasklist
|
||||
taskworker
|
||||
Taskworker
|
||||
taskworkers
|
||||
Taskworkers
|
||||
techdocs
|
||||
Telenor
|
||||
templated
|
||||
|
||||
@@ -58,6 +58,7 @@ export interface RouterOptions {
|
||||
database: PluginDatabaseManager;
|
||||
catalogClient: CatalogApi;
|
||||
actions?: TemplateAction<any>[];
|
||||
taskWorkers?: number;
|
||||
}
|
||||
|
||||
function isAlpha1Template(
|
||||
@@ -91,6 +92,7 @@ export async function createRouter(
|
||||
database,
|
||||
catalogClient,
|
||||
actions,
|
||||
taskWorkers,
|
||||
} = options;
|
||||
|
||||
const logger = parentLogger.child({ plugin: 'scaffolder' });
|
||||
@@ -103,11 +105,15 @@ export async function createRouter(
|
||||
);
|
||||
const taskBroker = new StorageTaskBroker(databaseTaskStore, logger);
|
||||
const actionRegistry = new TemplateActionRegistry();
|
||||
const worker = new TaskWorker({
|
||||
logger,
|
||||
taskBroker,
|
||||
actionRegistry,
|
||||
workingDirectory,
|
||||
const workers = new Array(taskWorkers || 1);
|
||||
workers.map(_ => {
|
||||
const worker = new TaskWorker({
|
||||
logger,
|
||||
taskBroker,
|
||||
actionRegistry,
|
||||
workingDirectory,
|
||||
});
|
||||
return worker;
|
||||
});
|
||||
|
||||
const actionsToRegister = Array.isArray(actions)
|
||||
@@ -127,8 +133,7 @@ export async function createRouter(
|
||||
];
|
||||
|
||||
actionsToRegister.forEach(action => actionRegistry.register(action));
|
||||
|
||||
worker.start();
|
||||
workers.forEach(worker => worker.start());
|
||||
|
||||
router
|
||||
.get(
|
||||
|
||||
Reference in New Issue
Block a user