@backstage/plugin-scaffolder-backend 1.8.1-next.0 → 1.9.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +25 -1
- package/dist/index.beta.d.ts +25 -1
- package/dist/index.cjs.js +30 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +25 -1
- package/package.json +18 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 1.9.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b32005e98a: Deprecated the `taskWorkers` option in RouterOptions in favor of `concurrentTasksLimit` which sets the limit of concurrent tasks in a single TaskWorker
|
|
8
|
+
|
|
9
|
+
TaskWorker can now run multiple (defaults to 10) tasks concurrently using the `concurrentTasksLimit` option available in both `RouterOptions` and `CreateWorkerOptions`.
|
|
10
|
+
|
|
11
|
+
To use the option to create a TaskWorker:
|
|
12
|
+
|
|
13
|
+
```diff
|
|
14
|
+
const worker = await TaskWorker.create({
|
|
15
|
+
taskBroker,
|
|
16
|
+
actionRegistry,
|
|
17
|
+
integrations,
|
|
18
|
+
logger,
|
|
19
|
+
workingDirectory,
|
|
20
|
+
additionalTemplateFilters,
|
|
21
|
+
+ concurrentTasksLimit: 10 // (1 to Infinity)
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 884d749b14: Refactored to use `coreServices` from `@backstage/backend-plugin-api`.
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @backstage/plugin-catalog-backend@1.6.0-next.2
|
|
30
|
+
- @backstage/plugin-catalog-node@1.3.0-next.2
|
|
31
|
+
- @backstage/backend-common@0.17.0-next.2
|
|
32
|
+
- @backstage/backend-plugin-api@0.2.0-next.2
|
|
33
|
+
- @backstage/backend-tasks@0.4.0-next.2
|
|
34
|
+
- @backstage/plugin-auth-node@0.2.8-next.2
|
|
35
|
+
- @backstage/catalog-client@1.2.0-next.1
|
|
36
|
+
- @backstage/catalog-model@1.1.4-next.1
|
|
37
|
+
- @backstage/config@1.0.5-next.1
|
|
38
|
+
- @backstage/errors@1.1.4-next.1
|
|
39
|
+
- @backstage/integration@1.4.1-next.1
|
|
40
|
+
- @backstage/types@1.0.2-next.1
|
|
41
|
+
- @backstage/plugin-scaffolder-common@1.2.3-next.1
|
|
42
|
+
|
|
43
|
+
## 1.8.1-next.1
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- c3fa90e184: Updated dependency `zen-observable` to `^0.10.0`.
|
|
48
|
+
- Updated dependencies
|
|
49
|
+
- @backstage/backend-common@0.17.0-next.1
|
|
50
|
+
- @backstage/plugin-catalog-backend@1.6.0-next.1
|
|
51
|
+
- @backstage/backend-tasks@0.4.0-next.1
|
|
52
|
+
- @backstage/types@1.0.2-next.1
|
|
53
|
+
- @backstage/backend-plugin-api@0.1.5-next.1
|
|
54
|
+
- @backstage/plugin-auth-node@0.2.8-next.1
|
|
55
|
+
- @backstage/plugin-catalog-node@1.2.2-next.1
|
|
56
|
+
- @backstage/config@1.0.5-next.1
|
|
57
|
+
- @backstage/integration@1.4.1-next.1
|
|
58
|
+
- @backstage/catalog-client@1.2.0-next.1
|
|
59
|
+
- @backstage/catalog-model@1.1.4-next.1
|
|
60
|
+
- @backstage/errors@1.1.4-next.1
|
|
61
|
+
- @backstage/plugin-scaffolder-common@1.2.3-next.1
|
|
62
|
+
|
|
3
63
|
## 1.8.1-next.0
|
|
4
64
|
|
|
5
65
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/index.alpha.d.ts
CHANGED
|
@@ -580,7 +580,7 @@ branchName: string;
|
|
|
580
580
|
sourcePath?: string | undefined;
|
|
581
581
|
targetPath?: string | undefined;
|
|
582
582
|
token?: string | undefined;
|
|
583
|
-
commitAction?: "update" | "
|
|
583
|
+
commitAction?: "update" | "delete" | "create" | undefined;
|
|
584
584
|
/** @deprecated projectID passed as query parameters in the repoUrl */
|
|
585
585
|
projectid?: string | undefined;
|
|
586
586
|
removeSourceBranch?: boolean | undefined;
|
|
@@ -611,6 +611,19 @@ export declare type CreateWorkerOptions = {
|
|
|
611
611
|
workingDirectory: string;
|
|
612
612
|
logger: Logger;
|
|
613
613
|
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
614
|
+
/**
|
|
615
|
+
* The number of tasks that can be executed at the same time by the worker
|
|
616
|
+
* @defaultValue 10
|
|
617
|
+
* @example
|
|
618
|
+
* ```
|
|
619
|
+
* {
|
|
620
|
+
* concurrentTasksLimit: 1,
|
|
621
|
+
* // OR
|
|
622
|
+
* concurrentTasksLimit: Infinity
|
|
623
|
+
* }
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
concurrentTasksLimit?: number;
|
|
614
627
|
additionalTemplateGlobals?: Record<string, TemplateGlobal>;
|
|
615
628
|
};
|
|
616
629
|
|
|
@@ -732,7 +745,16 @@ export declare interface RouterOptions {
|
|
|
732
745
|
catalogClient: CatalogApi;
|
|
733
746
|
scheduler?: PluginTaskScheduler;
|
|
734
747
|
actions?: TemplateAction<any>[];
|
|
748
|
+
/**
|
|
749
|
+
* @deprecated taskWorkers is deprecated in favor of concurrentTasksLimit option with a single TaskWorker
|
|
750
|
+
* @defaultValue 1
|
|
751
|
+
*/
|
|
735
752
|
taskWorkers?: number;
|
|
753
|
+
/**
|
|
754
|
+
* Sets the number of concurrent tasks that can be run at any given time on the TaskWorker
|
|
755
|
+
* @defaultValue 10
|
|
756
|
+
*/
|
|
757
|
+
concurrentTasksLimit?: number;
|
|
736
758
|
taskBroker?: TaskBroker;
|
|
737
759
|
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
738
760
|
additionalTemplateGlobals?: Record<string, TemplateGlobal>;
|
|
@@ -1015,8 +1037,10 @@ export declare type TaskStoreShutDownTaskOptions = {
|
|
|
1015
1037
|
export declare class TaskWorker {
|
|
1016
1038
|
private readonly options;
|
|
1017
1039
|
private constructor();
|
|
1040
|
+
private taskQueue;
|
|
1018
1041
|
static create(options: CreateWorkerOptions): Promise<TaskWorker>;
|
|
1019
1042
|
start(): void;
|
|
1043
|
+
protected onReadyToClaimTask(): Promise<void>;
|
|
1020
1044
|
runOneTask(task: TaskContext): Promise<void>;
|
|
1021
1045
|
}
|
|
1022
1046
|
|
package/dist/index.beta.d.ts
CHANGED
|
@@ -580,7 +580,7 @@ branchName: string;
|
|
|
580
580
|
sourcePath?: string | undefined;
|
|
581
581
|
targetPath?: string | undefined;
|
|
582
582
|
token?: string | undefined;
|
|
583
|
-
commitAction?: "update" | "
|
|
583
|
+
commitAction?: "update" | "delete" | "create" | undefined;
|
|
584
584
|
/** @deprecated projectID passed as query parameters in the repoUrl */
|
|
585
585
|
projectid?: string | undefined;
|
|
586
586
|
removeSourceBranch?: boolean | undefined;
|
|
@@ -611,6 +611,19 @@ export declare type CreateWorkerOptions = {
|
|
|
611
611
|
workingDirectory: string;
|
|
612
612
|
logger: Logger;
|
|
613
613
|
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
614
|
+
/**
|
|
615
|
+
* The number of tasks that can be executed at the same time by the worker
|
|
616
|
+
* @defaultValue 10
|
|
617
|
+
* @example
|
|
618
|
+
* ```
|
|
619
|
+
* {
|
|
620
|
+
* concurrentTasksLimit: 1,
|
|
621
|
+
* // OR
|
|
622
|
+
* concurrentTasksLimit: Infinity
|
|
623
|
+
* }
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
concurrentTasksLimit?: number;
|
|
614
627
|
additionalTemplateGlobals?: Record<string, TemplateGlobal>;
|
|
615
628
|
};
|
|
616
629
|
|
|
@@ -732,7 +745,16 @@ export declare interface RouterOptions {
|
|
|
732
745
|
catalogClient: CatalogApi;
|
|
733
746
|
scheduler?: PluginTaskScheduler;
|
|
734
747
|
actions?: TemplateAction<any>[];
|
|
748
|
+
/**
|
|
749
|
+
* @deprecated taskWorkers is deprecated in favor of concurrentTasksLimit option with a single TaskWorker
|
|
750
|
+
* @defaultValue 1
|
|
751
|
+
*/
|
|
735
752
|
taskWorkers?: number;
|
|
753
|
+
/**
|
|
754
|
+
* Sets the number of concurrent tasks that can be run at any given time on the TaskWorker
|
|
755
|
+
* @defaultValue 10
|
|
756
|
+
*/
|
|
757
|
+
concurrentTasksLimit?: number;
|
|
736
758
|
taskBroker?: TaskBroker;
|
|
737
759
|
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
738
760
|
additionalTemplateGlobals?: Record<string, TemplateGlobal>;
|
|
@@ -997,8 +1019,10 @@ export declare type TaskStoreShutDownTaskOptions = {
|
|
|
997
1019
|
export declare class TaskWorker {
|
|
998
1020
|
private readonly options;
|
|
999
1021
|
private constructor();
|
|
1022
|
+
private taskQueue;
|
|
1000
1023
|
static create(options: CreateWorkerOptions): Promise<TaskWorker>;
|
|
1001
1024
|
start(): void;
|
|
1025
|
+
protected onReadyToClaimTask(): Promise<void>;
|
|
1002
1026
|
runOneTask(task: TaskContext): Promise<void>;
|
|
1003
1027
|
}
|
|
1004
1028
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -26,6 +26,7 @@ var node = require('@gitbeaker/node');
|
|
|
26
26
|
var uuid = require('uuid');
|
|
27
27
|
var luxon = require('luxon');
|
|
28
28
|
var ObservableImpl = require('zen-observable');
|
|
29
|
+
var PQueue = require('p-queue');
|
|
29
30
|
var winston = require('winston');
|
|
30
31
|
var nunjucks = require('nunjucks');
|
|
31
32
|
var lodash = require('lodash');
|
|
@@ -69,6 +70,7 @@ var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
|
|
|
69
70
|
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
70
71
|
var limiterFactory__default = /*#__PURE__*/_interopDefaultLegacy(limiterFactory);
|
|
71
72
|
var ObservableImpl__default = /*#__PURE__*/_interopDefaultLegacy(ObservableImpl);
|
|
73
|
+
var PQueue__default = /*#__PURE__*/_interopDefaultLegacy(PQueue);
|
|
72
74
|
var winston__namespace = /*#__PURE__*/_interopNamespace(winston);
|
|
73
75
|
var nunjucks__default = /*#__PURE__*/_interopDefaultLegacy(nunjucks);
|
|
74
76
|
var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
@@ -4585,6 +4587,9 @@ function scaffoldingTracker() {
|
|
|
4585
4587
|
class TaskWorker {
|
|
4586
4588
|
constructor(options) {
|
|
4587
4589
|
this.options = options;
|
|
4590
|
+
this.taskQueue = new PQueue__default["default"]({
|
|
4591
|
+
concurrency: this.options.concurrentTasksLimit
|
|
4592
|
+
});
|
|
4588
4593
|
}
|
|
4589
4594
|
static async create(options) {
|
|
4590
4595
|
const {
|
|
@@ -4594,6 +4599,7 @@ class TaskWorker {
|
|
|
4594
4599
|
integrations,
|
|
4595
4600
|
workingDirectory,
|
|
4596
4601
|
additionalTemplateFilters,
|
|
4602
|
+
concurrentTasksLimit = 10,
|
|
4597
4603
|
additionalTemplateGlobals
|
|
4598
4604
|
} = options;
|
|
4599
4605
|
const workflowRunner = new NunjucksWorkflowRunner({
|
|
@@ -4606,17 +4612,29 @@ class TaskWorker {
|
|
|
4606
4612
|
});
|
|
4607
4613
|
return new TaskWorker({
|
|
4608
4614
|
taskBroker,
|
|
4609
|
-
runners: { workflowRunner }
|
|
4615
|
+
runners: { workflowRunner },
|
|
4616
|
+
concurrentTasksLimit
|
|
4610
4617
|
});
|
|
4611
4618
|
}
|
|
4612
4619
|
start() {
|
|
4613
4620
|
(async () => {
|
|
4614
4621
|
for (; ; ) {
|
|
4622
|
+
await this.onReadyToClaimTask();
|
|
4615
4623
|
const task = await this.options.taskBroker.claim();
|
|
4616
|
-
|
|
4624
|
+
this.taskQueue.add(() => this.runOneTask(task));
|
|
4617
4625
|
}
|
|
4618
4626
|
})();
|
|
4619
4627
|
}
|
|
4628
|
+
onReadyToClaimTask() {
|
|
4629
|
+
if (this.taskQueue.pending < this.options.concurrentTasksLimit) {
|
|
4630
|
+
return Promise.resolve();
|
|
4631
|
+
}
|
|
4632
|
+
return new Promise((resolve) => {
|
|
4633
|
+
this.taskQueue.once("next", () => {
|
|
4634
|
+
resolve();
|
|
4635
|
+
});
|
|
4636
|
+
});
|
|
4637
|
+
}
|
|
4620
4638
|
async runOneTask(task) {
|
|
4621
4639
|
try {
|
|
4622
4640
|
if (task.spec.apiVersion !== "scaffolder.backstage.io/v1beta3") {
|
|
@@ -4835,6 +4853,7 @@ async function createRouter(options) {
|
|
|
4835
4853
|
catalogClient,
|
|
4836
4854
|
actions,
|
|
4837
4855
|
taskWorkers,
|
|
4856
|
+
concurrentTasksLimit,
|
|
4838
4857
|
scheduler,
|
|
4839
4858
|
additionalTemplateFilters,
|
|
4840
4859
|
additionalTemplateGlobals
|
|
@@ -4868,7 +4887,7 @@ async function createRouter(options) {
|
|
|
4868
4887
|
}
|
|
4869
4888
|
const actionRegistry = new TemplateActionRegistry();
|
|
4870
4889
|
const workers = [];
|
|
4871
|
-
for (let i = 0; i < (taskWorkers ||
|
|
4890
|
+
for (let i = 0; i < (taskWorkers || 1); i++) {
|
|
4872
4891
|
const worker = await TaskWorker.create({
|
|
4873
4892
|
taskBroker,
|
|
4874
4893
|
actionRegistry,
|
|
@@ -4876,7 +4895,8 @@ async function createRouter(options) {
|
|
|
4876
4895
|
logger,
|
|
4877
4896
|
workingDirectory,
|
|
4878
4897
|
additionalTemplateFilters,
|
|
4879
|
-
additionalTemplateGlobals
|
|
4898
|
+
additionalTemplateGlobals,
|
|
4899
|
+
concurrentTasksLimit
|
|
4880
4900
|
});
|
|
4881
4901
|
workers.push(worker);
|
|
4882
4902
|
}
|
|
@@ -5273,12 +5293,12 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin({
|
|
|
5273
5293
|
);
|
|
5274
5294
|
env.registerInit({
|
|
5275
5295
|
deps: {
|
|
5276
|
-
logger: backendPluginApi.
|
|
5277
|
-
config: backendPluginApi.
|
|
5278
|
-
reader: backendPluginApi.
|
|
5279
|
-
permissions: backendPluginApi.
|
|
5280
|
-
database: backendPluginApi.
|
|
5281
|
-
httpRouter: backendPluginApi.
|
|
5296
|
+
logger: backendPluginApi.coreServices.logger,
|
|
5297
|
+
config: backendPluginApi.coreServices.config,
|
|
5298
|
+
reader: backendPluginApi.coreServices.urlReader,
|
|
5299
|
+
permissions: backendPluginApi.coreServices.permissions,
|
|
5300
|
+
database: backendPluginApi.coreServices.database,
|
|
5301
|
+
httpRouter: backendPluginApi.coreServices.httpRouter,
|
|
5282
5302
|
catalogClient: pluginCatalogNode.catalogServiceRef
|
|
5283
5303
|
},
|
|
5284
5304
|
async init({
|