@backstage-community/plugin-tech-insights-backend 2.1.0 → 2.1.1
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 +6 -0
- package/README.md +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/service/fact/FactRetrieverEngine.cjs.js.map +1 -1
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ lifecycle: { timeToLive: { weeks: 2 } }; # Human readable value
|
|
|
70
70
|
|
|
71
71
|
#### Running fact retrievers in a multi-instance installation
|
|
72
72
|
|
|
73
|
-
The Tech Insights plugin utilizes `
|
|
73
|
+
The Tech Insights plugin utilizes `SchedulerService` to schedule and coordinate task invocation across instances. See [the SchedulerService documentation](https://backstage.io/docs/reference/backend-plugin-api.schedulerservice/) for more information.
|
|
74
74
|
|
|
75
75
|
### Included FactChecker
|
|
76
76
|
|
package/dist/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ declare abstract class FactRetrieverEngine {
|
|
|
81
81
|
/**
|
|
82
82
|
* Schedules fact retriever run cycles based on configuration provided in the registration.
|
|
83
83
|
*
|
|
84
|
-
* Default implementation uses
|
|
84
|
+
* Default implementation uses SchedulerService to handle scheduling. This function can be called multiple
|
|
85
85
|
* times, where initial calls schedule the tasks and subsequent invocations update the schedules.
|
|
86
86
|
*/
|
|
87
87
|
abstract schedule(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FactRetrieverEngine.cjs.js","sources":["../../../src/service/fact/FactRetrieverEngine.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n FactLifecycle,\n FactRetriever,\n FactRetrieverContext,\n FactRetrieverRegistration,\n FactRetrieverRegistry,\n TechInsightFact,\n TechInsightsStore,\n} from '@backstage-community/plugin-tech-insights-node';\nimport { Duration } from 'luxon';\nimport { LoggerService, SchedulerService } from '@backstage/backend-plugin-api';\n\nfunction randomDailyCron() {\n const rand = (min: number, max: number) =>\n Math.floor(Math.random() * (max - min + 1) + min);\n return `${rand(0, 59)} ${rand(0, 23)} * * *`;\n}\n\nfunction duration(startTimestamp: [number, number]): string {\n const delta = process.hrtime(startTimestamp);\n const seconds = delta[0] + delta[1] / 1e9;\n return `${seconds.toFixed(1)}s`;\n}\n\n/**\n * @public\n *\n * FactRetrieverEngine responsible scheduling and running fact retrieval tasks.\n */\nexport abstract class FactRetrieverEngine {\n /**\n * Schedules fact retriever run cycles based on configuration provided in the registration.\n *\n * Default implementation uses backend-tasks to handle scheduling. This function can be called multiple\n * times, where initial calls schedule the tasks and subsequent invocations update the schedules.\n */\n abstract schedule(): Promise<void>;\n\n /**\n * Schedules single fact retriever run cycles based on configuration provided in the registration.\n *\n * Default implementation defers to scheduling all jobs\n */\n async scheduleJob(_: string): Promise<void> {\n return await this.schedule();\n }\n\n /**\n * Provides possibility to manually run a fact retriever job and construct fact data\n *\n * @param ref - Reference to the task name stored in the executor database. By convention this is the fact retriever id\n */\n abstract triggerJob(ref: string): Promise<void>;\n\n /**\n * Exposes fact retriever job configuration information about previous and next runs and schedule\n *\n * @param ref - Reference to the task name stored in the executor database. By convention this is the fact retriever id\n */\n abstract getJobRegistration(ref: string): Promise<FactRetrieverRegistration>;\n}\n\nexport class DefaultFactRetrieverEngine implements FactRetrieverEngine {\n private constructor(\n private readonly repository: TechInsightsStore,\n private readonly factRetrieverRegistry: FactRetrieverRegistry,\n private readonly factRetrieverContext: FactRetrieverContext,\n private readonly logger: LoggerService,\n private readonly scheduler: SchedulerService,\n private readonly defaultCadence?: string,\n private readonly defaultTimeout?: Duration,\n private readonly defaultInitialDelay?: Duration,\n ) {}\n\n static async create(options: {\n repository: TechInsightsStore;\n factRetrieverRegistry: FactRetrieverRegistry;\n factRetrieverContext: FactRetrieverContext;\n scheduler: SchedulerService;\n defaultCadence?: string;\n defaultTimeout?: Duration;\n defaultInitialDelay?: Duration;\n }) {\n const {\n repository,\n factRetrieverRegistry,\n factRetrieverContext,\n scheduler,\n defaultCadence,\n defaultTimeout,\n defaultInitialDelay,\n } = options;\n\n const retrievers = await factRetrieverRegistry.listRetrievers();\n await Promise.all(retrievers.map(it => repository.insertFactSchema(it)));\n\n return new DefaultFactRetrieverEngine(\n repository,\n factRetrieverRegistry,\n factRetrieverContext,\n factRetrieverContext.logger,\n scheduler,\n defaultCadence,\n defaultTimeout,\n defaultInitialDelay,\n );\n }\n\n private async scheduleRegistration(registration: FactRetrieverRegistration) {\n const { factRetriever, cadence, lifecycle, timeout, initialDelay } =\n registration;\n const cronExpression = cadence || this.defaultCadence || randomDailyCron();\n const timeLimit =\n timeout || this.defaultTimeout || Duration.fromObject({ minutes: 5 });\n const initialDelaySetting =\n initialDelay ||\n this.defaultInitialDelay ||\n Duration.fromObject({ seconds: 5 });\n\n await this.scheduler.scheduleTask({\n id: factRetriever.id,\n frequency: { cron: cronExpression },\n fn: this.createFactRetrieverHandler(factRetriever, lifecycle),\n timeout: timeLimit,\n // We add a delay in order to prevent errors due to the\n // fact that the backend is not yet online in a cold-start scenario\n initialDelay: initialDelaySetting,\n });\n }\n\n async scheduleJob(ref: string): Promise<void> {\n const registration = await this.factRetrieverRegistry.get(ref);\n return this.scheduleRegistration(registration);\n }\n\n async schedule() {\n const registrations = await this.factRetrieverRegistry.listRegistrations();\n const newRegs: string[] = [];\n\n await Promise.all(\n registrations.map(async registration => {\n try {\n await this.scheduleRegistration(registration);\n newRegs.push(registration.factRetriever.id);\n } catch (e) {\n this.logger.warn(\n `Failed to schedule fact retriever ${registration.factRetriever.id}, ${e}`,\n );\n }\n }),\n );\n\n this.logger.info(\n `Scheduled ${newRegs.length}/${registrations.length} fact retrievers into the tech-insights engine`,\n );\n }\n\n getJobRegistration(ref: string): Promise<FactRetrieverRegistration> {\n return this.factRetrieverRegistry.get(ref);\n }\n\n async triggerJob(ref: string): Promise<void> {\n await this.scheduler.triggerTask(ref);\n }\n\n private createFactRetrieverHandler(\n factRetriever: FactRetriever,\n lifecycle?: FactLifecycle,\n ) {\n return async () => {\n const startTimestamp = process.hrtime();\n this.logger.info(\n `Retrieving facts for fact retriever ${factRetriever.id}`,\n );\n\n let facts: TechInsightFact[] = [];\n try {\n facts = await factRetriever.handler({\n ...this.factRetrieverContext,\n logger: this.logger.child({ factRetrieverId: factRetriever.id }),\n entityFilter: factRetriever.entityFilter,\n });\n this.logger.debug(\n `Retrieved ${facts.length} facts for fact retriever ${\n factRetriever.id\n } in ${duration(startTimestamp)}`,\n );\n } catch (e) {\n this.logger.error(\n `Failed to retrieve facts for retriever ${factRetriever.id}`,\n e,\n );\n }\n\n try {\n await this.repository.insertFacts({\n id: factRetriever.id,\n facts,\n lifecycle,\n });\n this.logger.info(\n `Stored ${facts.length} facts for fact retriever ${\n factRetriever.id\n } in ${duration(startTimestamp)}`,\n );\n } catch (e) {\n this.logger.warn(\n `Failed to insert facts for fact retriever ${factRetriever.id}`,\n e,\n );\n }\n };\n }\n}\n"],"names":["Duration"],"mappings":";;;;AA2BA,SAAS,eAAkB,GAAA;AACzB,EAAA,MAAM,IAAO,GAAA,CAAC,GAAa,EAAA,GAAA,KACzB,IAAK,CAAA,KAAA,CAAM,IAAK,CAAA,MAAA,EAAY,IAAA,GAAA,GAAM,GAAM,GAAA,CAAA,CAAA,GAAK,GAAG,CAAA;AAClD,EAAO,OAAA,CAAA,EAAG,KAAK,CAAG,EAAA,EAAE,CAAC,CAAI,CAAA,EAAA,IAAA,CAAK,CAAG,EAAA,EAAE,CAAC,CAAA,MAAA,CAAA;AACtC;AAEA,S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K,MAAO,CAAA,KAAA;AAAA,UACV,CAAA,UAAA,EAAa,MAAM,MAAM,CAAA,0BAAA,EACvB,cAAc,EAChB,CAAA,IAAA,EAAO,QAAS,CAAA,cAAc,CAAC,CAAA;AAAA,SACjC;AAAA,eACO,CAAG,EAAA;AACV,QAAA,IAAA,CAAK,MAAO,CAAA,KAAA;AAAA,UACV,CAAA,uCAAA,EAA0C,cAAc,EAAE,CAAA,CAAA;AAAA,UAC1D;AAAA,SACF;AAAA;AAGF,MAAI,IAAA;AACF,QAAM,MAAA,IAAA,CAAK,WAAW,WAAY,CAAA;AAAA,UAChC,IAAI,aAAc,CAAA,EAAA;AAAA,UAClB,KAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,IAAA,CAAK,MAAO,CAAA,IAAA;AAAA,UACV,CAAA,OAAA,EAAU,MAAM,MAAM,CAAA,0BAAA,EACpB,cAAc,EAChB,CAAA,IAAA,EAAO,QAAS,CAAA,cAAc,CAAC,CAAA;AAAA,SACjC;AAAA,eACO,CAAG,EAAA;AACV,QAAA,IAAA,CAAK,MAAO,CAAA,IAAA;AAAA,UACV,CAAA,0CAAA,EAA6C,cAAc,EAAE,CAAA,CAAA;AAAA,UAC7D;AAAA,SACF;AAAA;AACF,KACF;AAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"FactRetrieverEngine.cjs.js","sources":["../../../src/service/fact/FactRetrieverEngine.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n FactLifecycle,\n FactRetriever,\n FactRetrieverContext,\n FactRetrieverRegistration,\n FactRetrieverRegistry,\n TechInsightFact,\n TechInsightsStore,\n} from '@backstage-community/plugin-tech-insights-node';\nimport { Duration } from 'luxon';\nimport { LoggerService, SchedulerService } from '@backstage/backend-plugin-api';\n\nfunction randomDailyCron() {\n const rand = (min: number, max: number) =>\n Math.floor(Math.random() * (max - min + 1) + min);\n return `${rand(0, 59)} ${rand(0, 23)} * * *`;\n}\n\nfunction duration(startTimestamp: [number, number]): string {\n const delta = process.hrtime(startTimestamp);\n const seconds = delta[0] + delta[1] / 1e9;\n return `${seconds.toFixed(1)}s`;\n}\n\n/**\n * @public\n *\n * FactRetrieverEngine responsible scheduling and running fact retrieval tasks.\n */\nexport abstract class FactRetrieverEngine {\n /**\n * Schedules fact retriever run cycles based on configuration provided in the registration.\n *\n * Default implementation uses SchedulerService to handle scheduling. This function can be called multiple\n * times, where initial calls schedule the tasks and subsequent invocations update the schedules.\n */\n abstract schedule(): Promise<void>;\n\n /**\n * Schedules single fact retriever run cycles based on configuration provided in the registration.\n *\n * Default implementation defers to scheduling all jobs\n */\n async scheduleJob(_: string): Promise<void> {\n return await this.schedule();\n }\n\n /**\n * Provides possibility to manually run a fact retriever job and construct fact data\n *\n * @param ref - Reference to the task name stored in the executor database. By convention this is the fact retriever id\n */\n abstract triggerJob(ref: string): Promise<void>;\n\n /**\n * Exposes fact retriever job configuration information about previous and next runs and schedule\n *\n * @param ref - Reference to the task name stored in the executor database. By convention this is the fact retriever id\n */\n abstract getJobRegistration(ref: string): Promise<FactRetrieverRegistration>;\n}\n\nexport class DefaultFactRetrieverEngine implements FactRetrieverEngine {\n private constructor(\n private readonly repository: TechInsightsStore,\n private readonly factRetrieverRegistry: FactRetrieverRegistry,\n private readonly factRetrieverContext: FactRetrieverContext,\n private readonly logger: LoggerService,\n private readonly scheduler: SchedulerService,\n private readonly defaultCadence?: string,\n private readonly defaultTimeout?: Duration,\n private readonly defaultInitialDelay?: Duration,\n ) {}\n\n static async create(options: {\n repository: TechInsightsStore;\n factRetrieverRegistry: FactRetrieverRegistry;\n factRetrieverContext: FactRetrieverContext;\n scheduler: SchedulerService;\n defaultCadence?: string;\n defaultTimeout?: Duration;\n defaultInitialDelay?: Duration;\n }) {\n const {\n repository,\n factRetrieverRegistry,\n factRetrieverContext,\n scheduler,\n defaultCadence,\n defaultTimeout,\n defaultInitialDelay,\n } = options;\n\n const retrievers = await factRetrieverRegistry.listRetrievers();\n await Promise.all(retrievers.map(it => repository.insertFactSchema(it)));\n\n return new DefaultFactRetrieverEngine(\n repository,\n factRetrieverRegistry,\n factRetrieverContext,\n factRetrieverContext.logger,\n scheduler,\n defaultCadence,\n defaultTimeout,\n defaultInitialDelay,\n );\n }\n\n private async scheduleRegistration(registration: FactRetrieverRegistration) {\n const { factRetriever, cadence, lifecycle, timeout, initialDelay } =\n registration;\n const cronExpression = cadence || this.defaultCadence || randomDailyCron();\n const timeLimit =\n timeout || this.defaultTimeout || Duration.fromObject({ minutes: 5 });\n const initialDelaySetting =\n initialDelay ||\n this.defaultInitialDelay ||\n Duration.fromObject({ seconds: 5 });\n\n await this.scheduler.scheduleTask({\n id: factRetriever.id,\n frequency: { cron: cronExpression },\n fn: this.createFactRetrieverHandler(factRetriever, lifecycle),\n timeout: timeLimit,\n // We add a delay in order to prevent errors due to the\n // fact that the backend is not yet online in a cold-start scenario\n initialDelay: initialDelaySetting,\n });\n }\n\n async scheduleJob(ref: string): Promise<void> {\n const registration = await this.factRetrieverRegistry.get(ref);\n return this.scheduleRegistration(registration);\n }\n\n async schedule() {\n const registrations = await this.factRetrieverRegistry.listRegistrations();\n const newRegs: string[] = [];\n\n await Promise.all(\n registrations.map(async registration => {\n try {\n await this.scheduleRegistration(registration);\n newRegs.push(registration.factRetriever.id);\n } catch (e) {\n this.logger.warn(\n `Failed to schedule fact retriever ${registration.factRetriever.id}, ${e}`,\n );\n }\n }),\n );\n\n this.logger.info(\n `Scheduled ${newRegs.length}/${registrations.length} fact retrievers into the tech-insights engine`,\n );\n }\n\n getJobRegistration(ref: string): Promise<FactRetrieverRegistration> {\n return this.factRetrieverRegistry.get(ref);\n }\n\n async triggerJob(ref: string): Promise<void> {\n await this.scheduler.triggerTask(ref);\n }\n\n private createFactRetrieverHandler(\n factRetriever: FactRetriever,\n lifecycle?: FactLifecycle,\n ) {\n return async () => {\n const startTimestamp = process.hrtime();\n this.logger.info(\n `Retrieving facts for fact retriever ${factRetriever.id}`,\n );\n\n let facts: TechInsightFact[] = [];\n try {\n facts = await factRetriever.handler({\n ...this.factRetrieverContext,\n logger: this.logger.child({ factRetrieverId: factRetriever.id }),\n entityFilter: factRetriever.entityFilter,\n });\n this.logger.debug(\n `Retrieved ${facts.length} facts for fact retriever ${\n factRetriever.id\n } in ${duration(startTimestamp)}`,\n );\n } catch (e) {\n this.logger.error(\n `Failed to retrieve facts for retriever ${factRetriever.id}`,\n e,\n );\n }\n\n try {\n await this.repository.insertFacts({\n id: factRetriever.id,\n facts,\n lifecycle,\n });\n this.logger.info(\n `Stored ${facts.length} facts for fact retriever ${\n factRetriever.id\n } in ${duration(startTimestamp)}`,\n );\n } catch (e) {\n this.logger.warn(\n `Failed to insert facts for fact retriever ${factRetriever.id}`,\n e,\n );\n }\n };\n }\n}\n"],"names":["Duration"],"mappings":";;;;AA2BA,SAAS,eAAkB,GAAA;AACzB,EAAA,MAAM,IAAO,GAAA,CAAC,GAAa,EAAA,GAAA,KACzB,IAAK,CAAA,KAAA,CAAM,IAAK,CAAA,MAAA,EAAY,IAAA,GAAA,GAAM,GAAM,GAAA,CAAA,CAAA,GAAK,GAAG,CAAA;AAClD,EAAO,OAAA,CAAA,EAAG,KAAK,CAAG,EAAA,EAAE,CAAC,CAAI,CAAA,EAAA,IAAA,CAAK,CAAG,EAAA,EAAE,CAAC,CAAA,MAAA,CAAA;AACtC;AAEA,SAAS,SAAS,cAA0C,EAAA;AAC1D,EAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,MAAA,CAAO,cAAc,CAAA;AAC3C,EAAA,MAAM,UAAU,KAAM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AAc,CAAC,CAAA;AAAA,SACjC;AAAA,eACO,CAAG,EAAA;AACV,QAAA,IAAA,CAAK,MAAO,CAAA,KAAA;AAAA,UACV,CAAA,uCAAA,EAA0C,cAAc,EAAE,CAAA,CAAA;AAAA,UAC1D;AAAA,SACF;AAAA;AAGF,MAAI,IAAA;AACF,QAAM,MAAA,IAAA,CAAK,WAAW,WAAY,CAAA;AAAA,UAChC,IAAI,aAAc,CAAA,EAAA;AAAA,UAClB,KAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,IAAA,CAAK,MAAO,CAAA,IAAA;AAAA,UACV,CAAA,OAAA,EAAU,MAAM,MAAM,CAAA,0BAAA,EACpB,cAAc,EAChB,CAAA,IAAA,EAAO,QAAS,CAAA,cAAc,CAAC,CAAA;AAAA,SACjC;AAAA,eACO,CAAG,EAAA;AACV,QAAA,IAAA,CAAK,MAAO,CAAA,IAAA;AAAA,UACV,CAAA,0CAAA,EAA6C,cAAc,EAAE,CAAA,CAAA;AAAA,UAC7D;AAAA,SACF;AAAA;AACF,KACF;AAAA;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-tech-insights-backend",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin",
|
|
6
6
|
"pluginId": "tech-insights",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"@backstage-community/plugin-tech-insights-node": "^2.2.0",
|
|
50
50
|
"@backstage/backend-defaults": "^0.6.2",
|
|
51
51
|
"@backstage/backend-plugin-api": "^1.1.0",
|
|
52
|
-
"@backstage/backend-tasks": "^0.6.1",
|
|
53
52
|
"@backstage/backend-test-utils": "^1.2.0",
|
|
54
53
|
"@backstage/catalog-client": "^1.9.0",
|
|
55
54
|
"@backstage/catalog-model": "^1.7.2",
|