@backstage/backend-app-api 1.5.0 → 1.6.0-next.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
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @backstage/backend-app-api
|
|
2
2
|
|
|
3
|
+
## 1.6.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 545557a: Registration errors should be forwarded as BackendStartupResult
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/backend-plugin-api@1.8.0-next.1
|
|
13
|
+
|
|
14
|
+
## 1.5.1-next.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/backend-plugin-api@1.7.1-next.0
|
|
20
|
+
- @backstage/config@1.3.6
|
|
21
|
+
- @backstage/errors@1.2.7
|
|
22
|
+
|
|
3
23
|
## 1.5.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -203,69 +203,6 @@ class BackendInitializer {
|
|
|
203
203
|
process.on("uncaughtException", this.#uncaughtExceptionHandler);
|
|
204
204
|
}
|
|
205
205
|
await this.#serviceRegistry.initializeEagerServicesWithScope("root");
|
|
206
|
-
const pluginInits = /* @__PURE__ */ new Map();
|
|
207
|
-
const moduleInits = /* @__PURE__ */ new Map();
|
|
208
|
-
for (const feature of this.#registrations) {
|
|
209
|
-
for (const r of feature.getRegistrations()) {
|
|
210
|
-
const provides = /* @__PURE__ */ new Set();
|
|
211
|
-
if (r.type === "plugin" || r.type === "module") {
|
|
212
|
-
for (const [extRef, extImpl] of r.extensionPoints) {
|
|
213
|
-
if (this.#extensionPoints.has(extRef.id)) {
|
|
214
|
-
throw new Error(
|
|
215
|
-
`ExtensionPoint with ID '${extRef.id}' is already registered`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
this.#extensionPoints.set(extRef.id, {
|
|
219
|
-
pluginId: r.pluginId,
|
|
220
|
-
factory: () => extImpl
|
|
221
|
-
});
|
|
222
|
-
provides.add(extRef);
|
|
223
|
-
}
|
|
224
|
-
} else if (r.type === "plugin-v1.1" || r.type === "module-v1.1") {
|
|
225
|
-
for (const extReg of r.extensionPoints) {
|
|
226
|
-
if (this.#extensionPoints.has(extReg.extensionPoint.id)) {
|
|
227
|
-
throw new Error(
|
|
228
|
-
`ExtensionPoint with ID '${extReg.extensionPoint.id}' is already registered`
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
this.#extensionPoints.set(extReg.extensionPoint.id, {
|
|
232
|
-
pluginId: r.pluginId,
|
|
233
|
-
factory: extReg.factory
|
|
234
|
-
});
|
|
235
|
-
provides.add(extReg.extensionPoint);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (r.type === "plugin" || r.type === "plugin-v1.1") {
|
|
239
|
-
if (pluginInits.has(r.pluginId)) {
|
|
240
|
-
throw new Error(`Plugin '${r.pluginId}' is already registered`);
|
|
241
|
-
}
|
|
242
|
-
pluginInits.set(r.pluginId, {
|
|
243
|
-
provides,
|
|
244
|
-
consumes: new Set(Object.values(r.init.deps)),
|
|
245
|
-
init: r.init
|
|
246
|
-
});
|
|
247
|
-
} else if (r.type === "module" || r.type === "module-v1.1") {
|
|
248
|
-
let modules = moduleInits.get(r.pluginId);
|
|
249
|
-
if (!modules) {
|
|
250
|
-
modules = /* @__PURE__ */ new Map();
|
|
251
|
-
moduleInits.set(r.pluginId, modules);
|
|
252
|
-
}
|
|
253
|
-
if (modules.has(r.moduleId)) {
|
|
254
|
-
throw new Error(
|
|
255
|
-
`Module '${r.moduleId}' for plugin '${r.pluginId}' is already registered`
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
modules.set(r.moduleId, {
|
|
259
|
-
provides,
|
|
260
|
-
consumes: new Set(Object.values(r.init.deps)),
|
|
261
|
-
init: r.init
|
|
262
|
-
});
|
|
263
|
-
} else {
|
|
264
|
-
throw new Error(`Invalid registration type '${r.type}'`);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
const pluginIds = [...pluginInits.keys()];
|
|
269
206
|
const rootConfig = await this.#serviceRegistry.get(
|
|
270
207
|
backendPluginApi.coreServices.rootConfig,
|
|
271
208
|
"root"
|
|
@@ -274,13 +211,27 @@ class BackendInitializer {
|
|
|
274
211
|
backendPluginApi.coreServices.rootLogger,
|
|
275
212
|
"root"
|
|
276
213
|
);
|
|
214
|
+
const allRegistrations = this.#registrations.flatMap(
|
|
215
|
+
(f) => f.getRegistrations()
|
|
216
|
+
);
|
|
217
|
+
const allPluginIds = [
|
|
218
|
+
...new Set(
|
|
219
|
+
allRegistrations.flatMap(
|
|
220
|
+
(r) => "pluginId" in r && typeof r.pluginId === "string" ? [r.pluginId] : []
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
];
|
|
277
224
|
const resultCollector = createInitializationResultCollector.createInitializationResultCollector({
|
|
278
|
-
pluginIds,
|
|
225
|
+
pluginIds: allPluginIds,
|
|
279
226
|
logger: rootLogger,
|
|
280
227
|
allowBootFailurePredicate: createAllowBootFailurePredicate.createAllowBootFailurePredicate(rootConfig)
|
|
281
228
|
});
|
|
229
|
+
const { pluginInits, moduleInits } = this.#enumerateRegistrations(
|
|
230
|
+
allRegistrations,
|
|
231
|
+
resultCollector
|
|
232
|
+
);
|
|
282
233
|
await Promise.all(
|
|
283
|
-
|
|
234
|
+
[...pluginInits.keys()].map(async (pluginId) => {
|
|
284
235
|
try {
|
|
285
236
|
await this.#serviceRegistry.initializeEagerServicesWithScope(
|
|
286
237
|
"plugin",
|
|
@@ -357,6 +308,88 @@ class BackendInitializer {
|
|
|
357
308
|
await lifecycleService.startup();
|
|
358
309
|
return { result };
|
|
359
310
|
}
|
|
311
|
+
#enumerateRegistrations(allRegistrations, resultCollector) {
|
|
312
|
+
const pluginInits = /* @__PURE__ */ new Map();
|
|
313
|
+
const moduleInits = /* @__PURE__ */ new Map();
|
|
314
|
+
for (const r of allRegistrations) {
|
|
315
|
+
const addedExtensionPointIds = [];
|
|
316
|
+
try {
|
|
317
|
+
const provides = /* @__PURE__ */ new Set();
|
|
318
|
+
if (r.type === "plugin" || r.type === "module") {
|
|
319
|
+
for (const [extRef, extImpl] of r.extensionPoints) {
|
|
320
|
+
if (this.#extensionPoints.has(extRef.id)) {
|
|
321
|
+
throw new Error(
|
|
322
|
+
`ExtensionPoint with ID '${extRef.id}' is already registered`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
this.#extensionPoints.set(extRef.id, {
|
|
326
|
+
pluginId: r.pluginId,
|
|
327
|
+
factory: () => extImpl
|
|
328
|
+
});
|
|
329
|
+
addedExtensionPointIds.push(extRef.id);
|
|
330
|
+
provides.add(extRef);
|
|
331
|
+
}
|
|
332
|
+
} else if (r.type === "plugin-v1.1" || r.type === "module-v1.1") {
|
|
333
|
+
for (const extReg of r.extensionPoints) {
|
|
334
|
+
if (this.#extensionPoints.has(extReg.extensionPoint.id)) {
|
|
335
|
+
throw new Error(
|
|
336
|
+
`ExtensionPoint with ID '${extReg.extensionPoint.id}' is already registered`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
this.#extensionPoints.set(extReg.extensionPoint.id, {
|
|
340
|
+
pluginId: r.pluginId,
|
|
341
|
+
factory: extReg.factory
|
|
342
|
+
});
|
|
343
|
+
addedExtensionPointIds.push(extReg.extensionPoint.id);
|
|
344
|
+
provides.add(extReg.extensionPoint);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (r.type === "plugin" || r.type === "plugin-v1.1") {
|
|
348
|
+
if (pluginInits.has(r.pluginId)) {
|
|
349
|
+
throw new Error(`Plugin '${r.pluginId}' is already registered`);
|
|
350
|
+
}
|
|
351
|
+
pluginInits.set(r.pluginId, {
|
|
352
|
+
provides,
|
|
353
|
+
consumes: new Set(Object.values(r.init.deps)),
|
|
354
|
+
init: r.init
|
|
355
|
+
});
|
|
356
|
+
} else if (r.type === "module" || r.type === "module-v1.1") {
|
|
357
|
+
let modules = moduleInits.get(r.pluginId);
|
|
358
|
+
if (!modules) {
|
|
359
|
+
modules = /* @__PURE__ */ new Map();
|
|
360
|
+
moduleInits.set(r.pluginId, modules);
|
|
361
|
+
}
|
|
362
|
+
if (modules.has(r.moduleId)) {
|
|
363
|
+
throw new Error(
|
|
364
|
+
`Module '${r.moduleId}' for plugin '${r.pluginId}' is already registered`
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
modules.set(r.moduleId, {
|
|
368
|
+
provides,
|
|
369
|
+
consumes: new Set(Object.values(r.init.deps)),
|
|
370
|
+
init: r.init
|
|
371
|
+
});
|
|
372
|
+
} else {
|
|
373
|
+
throw new Error(`Invalid registration type '${r.type}'`);
|
|
374
|
+
}
|
|
375
|
+
} catch (error) {
|
|
376
|
+
errors.assertError(error);
|
|
377
|
+
for (const id of addedExtensionPointIds) {
|
|
378
|
+
this.#extensionPoints.delete(id);
|
|
379
|
+
}
|
|
380
|
+
if ("pluginId" in r && "moduleId" in r) {
|
|
381
|
+
resultCollector.onPluginModuleResult(r.pluginId, r.moduleId, error);
|
|
382
|
+
} else if ("pluginId" in r) {
|
|
383
|
+
pluginInits.delete(r.pluginId);
|
|
384
|
+
moduleInits.delete(r.pluginId);
|
|
385
|
+
resultCollector.onPluginResult(r.pluginId, error);
|
|
386
|
+
} else {
|
|
387
|
+
throw error;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return { pluginInits, moduleInits };
|
|
392
|
+
}
|
|
360
393
|
// It's fine to call .stop() multiple times, which for example can happen with manual stop + process exit
|
|
361
394
|
async stop() {
|
|
362
395
|
instanceRegistry.unregister(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackendInitializer.cjs.js","sources":["../../src/wiring/BackendInitializer.ts"],"sourcesContent":["/*\n * Copyright 2022 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 */\n\nimport {\n BackendFeature,\n ExtensionPoint,\n coreServices,\n ServiceRef,\n ServiceFactory,\n LifecycleService,\n RootLifecycleService,\n createServiceFactory,\n ExtensionPointFactoryContext,\n} from '@backstage/backend-plugin-api';\nimport { ServiceOrExtensionPoint } from './types';\n// Direct internal import to avoid duplication\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type {\n InternalBackendFeature,\n InternalBackendFeatureLoader,\n InternalBackendRegistrations,\n} from '../../../backend-plugin-api/src/wiring/types';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type { InternalServiceFactory } from '../../../backend-plugin-api/src/services/system/types';\nimport { ForwardedError, ConflictError, assertError } from '@backstage/errors';\nimport { DependencyGraph } from '../lib/DependencyGraph';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { createInitializationResultCollector } from './createInitializationResultCollector';\nimport { deepFreeze, unwrapFeature } from './helpers';\nimport type { RootInstanceMetadataServicePluginInfo } from '@backstage/backend-plugin-api';\nimport { BackendStartupResult } from './types';\nimport { BackendStartupError } from './BackendStartupError';\nimport { createAllowBootFailurePredicate } from './createAllowBootFailurePredicate';\n\nexport interface BackendRegisterInit {\n consumes: Set<ServiceOrExtensionPoint>;\n provides: Set<ServiceOrExtensionPoint>;\n init: {\n deps: { [name: string]: ServiceOrExtensionPoint };\n func: (deps: { [name: string]: unknown }) => Promise<void>;\n };\n}\n\n/**\n * A registry of backend instances, used to manage process shutdown hooks across all instances.\n */\nconst instanceRegistry = new (class InstanceRegistry {\n #registered = false;\n #instances = new Set<BackendInitializer>();\n\n register(instance: BackendInitializer) {\n if (!this.#registered) {\n this.#registered = true;\n\n process.addListener('SIGTERM', this.#exitHandler);\n process.addListener('SIGINT', this.#exitHandler);\n process.addListener('beforeExit', this.#exitHandler);\n }\n\n this.#instances.add(instance);\n }\n\n unregister(instance: BackendInitializer) {\n this.#instances.delete(instance);\n }\n\n #exitHandler = async () => {\n try {\n const results = await Promise.allSettled(\n Array.from(this.#instances).map(b => b.stop()),\n );\n const errors = results.flatMap(r =>\n r.status === 'rejected' ? [r.reason] : [],\n );\n\n if (errors.length > 0) {\n for (const error of errors) {\n console.error(error);\n }\n process.exit(1);\n } else {\n process.exit(0);\n }\n } catch (error) {\n console.error(error);\n process.exit(1);\n }\n };\n})();\n\nfunction createRootInstanceMetadataServiceFactory(\n rawRegistrations: InternalBackendRegistrations[],\n) {\n const installedPlugins: Map<string, RootInstanceMetadataServicePluginInfo> =\n new Map();\n const registrations = rawRegistrations\n .filter(registration => registration.featureType === 'registrations')\n .flatMap(registration => registration.getRegistrations());\n const plugins = registrations.filter(\n registration =>\n registration.type === 'plugin' || registration.type === 'plugin-v1.1',\n );\n const modules = registrations.filter(\n registration =>\n registration.type === 'module' || registration.type === 'module-v1.1',\n );\n for (const plugin of plugins) {\n const { pluginId } = plugin;\n if (!installedPlugins.get(pluginId)) {\n installedPlugins.set(pluginId, {\n pluginId,\n modules: [],\n });\n }\n }\n for (const module of modules) {\n const { pluginId, moduleId } = module;\n const installedPlugin = installedPlugins.get(pluginId);\n if (installedPlugin) {\n (installedPlugin.modules as Array<{ moduleId: string }>).push({\n moduleId,\n });\n }\n }\n\n return createServiceFactory({\n service: coreServices.rootInstanceMetadata,\n deps: {},\n factory: async () => {\n const readonlyInstalledPlugins = deepFreeze([\n ...installedPlugins.values(),\n ]);\n const instanceMetadata = {\n getInstalledPlugins: () => Promise.resolve(readonlyInstalledPlugins),\n };\n\n return instanceMetadata;\n },\n });\n}\n\nexport class BackendInitializer {\n #startPromise?: Promise<{ result: BackendStartupResult }>;\n #stopPromise?: Promise<void>;\n #registrations = new Array<InternalBackendRegistrations>();\n #extensionPoints = new Map<\n string,\n {\n pluginId: string;\n factory: (context: ExtensionPointFactoryContext) => unknown;\n }\n >();\n #serviceRegistry: ServiceRegistry;\n #registeredFeatures = new Array<Promise<BackendFeature>>();\n #registeredFeatureLoaders = new Array<InternalBackendFeatureLoader>();\n #unhandledRejectionHandler?: (reason: Error) => void;\n #uncaughtExceptionHandler?: (error: Error) => void;\n\n constructor(defaultApiFactories: ServiceFactory[]) {\n this.#serviceRegistry = ServiceRegistry.create([...defaultApiFactories]);\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n resultCollector: ReturnType<typeof createInitializationResultCollector>,\n pluginId: string,\n moduleId?: string,\n ) {\n const result = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(deps)) {\n const ep = this.#extensionPoints.get(ref.id);\n if (ep) {\n if (ep.pluginId !== pluginId) {\n throw new Error(\n `Illegal dependency: Module '${moduleId}' for plugin '${pluginId}' attempted to depend on extension point '${ref.id}' for plugin '${ep.pluginId}'. Extension points can only be used within their plugin's scope.`,\n );\n }\n if (!moduleId) {\n throw new Error(\n `Rejected dependency on extension point ${ref.id} from outside of a module`,\n );\n }\n result.set(\n name,\n ep.factory({\n reportModuleStartupFailure: ({ error }) => {\n resultCollector.amendPluginModuleResult(\n pluginId,\n moduleId,\n error,\n );\n },\n }),\n );\n } else {\n const impl = await this.#serviceRegistry.get(\n ref as ServiceRef<unknown>,\n pluginId,\n );\n if (impl) {\n result.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n const target = moduleId\n ? `module '${moduleId}' for plugin '${pluginId}'`\n : `plugin '${pluginId}'`;\n throw new Error(\n `Service or extension point dependencies of ${target} are missing for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add(feature: BackendFeature | Promise<BackendFeature>) {\n if (this.#startPromise) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#registeredFeatures.push(Promise.resolve(feature));\n }\n\n #addFeature(feature: BackendFeature) {\n if (isServiceFactory(feature)) {\n this.#serviceRegistry.add(feature);\n } else if (isBackendFeatureLoader(feature)) {\n this.#registeredFeatureLoaders.push(feature);\n } else if (isBackendRegistrations(feature)) {\n this.#registrations.push(feature);\n } else {\n throw new Error(\n `Failed to add feature, invalid feature ${JSON.stringify(feature)}`,\n );\n }\n }\n\n async start(): Promise<{ result: BackendStartupResult }> {\n if (this.#startPromise) {\n throw new Error('Backend has already started');\n }\n if (this.#stopPromise) {\n throw new Error('Backend has already stopped');\n }\n\n instanceRegistry.register(this);\n\n this.#startPromise = this.#doStart();\n return await this.#startPromise;\n }\n\n async #doStart(): Promise<{ result: BackendStartupResult }> {\n this.#serviceRegistry.checkForCircularDeps();\n\n for (const feature of this.#registeredFeatures) {\n this.#addFeature(await feature);\n }\n\n await this.#applyBackendFeatureLoaders(this.#registeredFeatureLoaders);\n\n this.#serviceRegistry.add(\n createRootInstanceMetadataServiceFactory(this.#registrations),\n );\n\n // This makes sure that any uncaught errors or unhandled rejections are\n // caught and logged, rather than terminating the process. We register these\n // as early as possible while still using the root logger service, the\n // tradeoff that if there are any unhandled errors as part of the that\n // instationation, it will cause the process to crash. If there are multiple\n // backend instances, each instance will log the error, because we can't\n // determine which instance the error came from.\n if (process.env.NODE_ENV !== 'test') {\n const rootLogger = await this.#serviceRegistry.get(\n coreServices.rootLogger,\n 'root',\n );\n this.#unhandledRejectionHandler = (reason: Error) => {\n rootLogger\n ?.child({ type: 'unhandledRejection' })\n ?.error('Unhandled rejection', reason);\n };\n this.#uncaughtExceptionHandler = (error: Error) => {\n rootLogger\n ?.child({ type: 'uncaughtException' })\n ?.error('Uncaught exception', error);\n };\n process.on('unhandledRejection', this.#unhandledRejectionHandler);\n process.on('uncaughtException', this.#uncaughtExceptionHandler);\n }\n\n // Initialize all root scoped services\n await this.#serviceRegistry.initializeEagerServicesWithScope('root');\n\n const pluginInits = new Map<string, BackendRegisterInit>();\n const moduleInits = new Map<string, Map<string, BackendRegisterInit>>();\n\n // Enumerate all registrations\n for (const feature of this.#registrations) {\n for (const r of feature.getRegistrations()) {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n if (r.type === 'plugin' || r.type === 'module') {\n // Handle v1 format: Array<readonly [ExtensionPoint<unknown>, unknown]>\n for (const [extRef, extImpl] of r.extensionPoints) {\n if (this.#extensionPoints.has(extRef.id)) {\n throw new Error(\n `ExtensionPoint with ID '${extRef.id}' is already registered`,\n );\n }\n this.#extensionPoints.set(extRef.id, {\n pluginId: r.pluginId,\n factory: () => extImpl,\n });\n provides.add(extRef);\n }\n } else if (r.type === 'plugin-v1.1' || r.type === 'module-v1.1') {\n // Handle v1.1 format: Array<ExtensionPointRegistration>\n for (const extReg of r.extensionPoints) {\n if (this.#extensionPoints.has(extReg.extensionPoint.id)) {\n throw new Error(\n `ExtensionPoint with ID '${extReg.extensionPoint.id}' is already registered`,\n );\n }\n this.#extensionPoints.set(extReg.extensionPoint.id, {\n pluginId: r.pluginId,\n factory: extReg.factory,\n });\n provides.add(extReg.extensionPoint);\n }\n }\n\n if (r.type === 'plugin' || r.type === 'plugin-v1.1') {\n if (pluginInits.has(r.pluginId)) {\n throw new Error(`Plugin '${r.pluginId}' is already registered`);\n }\n pluginInits.set(r.pluginId, {\n provides,\n consumes: new Set(Object.values(r.init.deps)),\n init: r.init,\n });\n } else if (r.type === 'module' || r.type === 'module-v1.1') {\n let modules = moduleInits.get(r.pluginId);\n if (!modules) {\n modules = new Map();\n moduleInits.set(r.pluginId, modules);\n }\n if (modules.has(r.moduleId)) {\n throw new Error(\n `Module '${r.moduleId}' for plugin '${r.pluginId}' is already registered`,\n );\n }\n modules.set(r.moduleId, {\n provides,\n consumes: new Set(Object.values(r.init.deps)),\n init: r.init,\n });\n } else {\n throw new Error(`Invalid registration type '${(r as any).type}'`);\n }\n }\n }\n\n const pluginIds = [...pluginInits.keys()];\n\n const rootConfig = await this.#serviceRegistry.get(\n coreServices.rootConfig,\n 'root',\n );\n const rootLogger = await this.#serviceRegistry.get(\n coreServices.rootLogger,\n 'root',\n );\n\n const resultCollector = createInitializationResultCollector({\n pluginIds,\n logger: rootLogger,\n allowBootFailurePredicate: createAllowBootFailurePredicate(rootConfig),\n });\n\n // All plugins are initialized in parallel\n await Promise.all(\n pluginIds.map(async pluginId => {\n try {\n // Initialize all eager services\n await this.#serviceRegistry.initializeEagerServicesWithScope(\n 'plugin',\n pluginId,\n );\n\n // Modules are initialized before plugins, so that they can provide extension to the plugin\n const modules = moduleInits.get(pluginId);\n if (modules) {\n const tree = DependencyGraph.fromIterable(\n Array.from(modules).map(([moduleId, moduleInit]) => ({\n value: { moduleId, moduleInit },\n // Relationships are reversed at this point since we're only interested in the extension points.\n // If a modules provides extension point A we want it to be initialized AFTER all modules\n // that depend on extension point A, so that they can provide their extensions.\n consumes: Array.from(moduleInit.provides).map(p => p.id),\n provides: Array.from(moduleInit.consumes).map(c => c.id),\n })),\n );\n const circular = tree.detectCircularDependency();\n if (circular) {\n throw new ConflictError(\n `Circular dependency detected for modules of plugin '${pluginId}', ${circular\n .map(({ moduleId }) => `'${moduleId}'`)\n .join(' -> ')}`,\n );\n }\n await tree.parallelTopologicalTraversal(\n async ({ moduleId, moduleInit }) => {\n try {\n const moduleDeps = await this.#getInitDeps(\n moduleInit.init.deps,\n resultCollector,\n pluginId,\n moduleId,\n );\n await moduleInit.init.func(moduleDeps);\n resultCollector.onPluginModuleResult(pluginId, moduleId);\n } catch (error: unknown) {\n assertError(error);\n resultCollector.onPluginModuleResult(\n pluginId,\n moduleId,\n error,\n );\n }\n },\n );\n }\n\n // Once all modules have been initialized, we can initialize the plugin itself\n const pluginInit = pluginInits.get(pluginId);\n // We allow modules to be installed without the accompanying plugin, so the plugin may not exist\n if (pluginInit) {\n const pluginDeps = await this.#getInitDeps(\n pluginInit.init.deps,\n resultCollector,\n pluginId,\n );\n await pluginInit.init.func(pluginDeps);\n }\n\n resultCollector.onPluginResult(pluginId);\n\n // Once the plugin and all modules have been initialized, we can signal that the plugin has stared up successfully\n const lifecycleService = await this.#getPluginLifecycleImpl(pluginId);\n await lifecycleService.startup();\n } catch (error: unknown) {\n assertError(error);\n resultCollector.onPluginResult(pluginId, error);\n }\n }),\n ).catch(error => {\n throw new ForwardedError(\n 'Unexpected uncaught backend startup error',\n error,\n );\n });\n\n const result = resultCollector.finalize();\n if (result.outcome === 'failure') {\n throw new BackendStartupError(result);\n }\n\n // Once all plugins and modules have been initialized, we can signal that the backend has started up successfully\n const lifecycleService = await this.#getRootLifecycleImpl();\n await lifecycleService.startup();\n\n return { result };\n }\n\n // It's fine to call .stop() multiple times, which for example can happen with manual stop + process exit\n async stop(): Promise<void> {\n instanceRegistry.unregister(this);\n\n if (!this.#stopPromise) {\n this.#stopPromise = this.#doStop();\n }\n await this.#stopPromise;\n }\n\n async #doStop(): Promise<void> {\n if (!this.#startPromise) {\n return;\n }\n\n try {\n await this.#startPromise;\n } catch (error) {\n // The startup failed, but we may still want to do cleanup so we continue silently\n }\n\n const rootLifecycleService = await this.#getRootLifecycleImpl();\n\n // Root services like the health one need to immediately be notified of the shutdown\n await rootLifecycleService.beforeShutdown();\n\n // Get all plugins.\n const allPlugins = new Set<string>();\n for (const feature of this.#registrations) {\n for (const r of feature.getRegistrations()) {\n if (r.type === 'plugin' || r.type === 'plugin-v1.1') {\n allPlugins.add(r.pluginId);\n }\n }\n }\n\n // Iterate through all plugins and run their shutdown hooks.\n await Promise.allSettled(\n [...allPlugins].map(async pluginId => {\n const lifecycleService = await this.#getPluginLifecycleImpl(pluginId);\n await lifecycleService.shutdown();\n }),\n );\n\n // Once all plugin shutdown hooks are done, run root shutdown hooks.\n await rootLifecycleService.shutdown();\n\n // Clean up process event listeners to prevent memory leaks and duplicate logging\n if (this.#unhandledRejectionHandler) {\n process.off('unhandledRejection', this.#unhandledRejectionHandler);\n this.#unhandledRejectionHandler = undefined;\n }\n if (this.#uncaughtExceptionHandler) {\n process.off('uncaughtException', this.#uncaughtExceptionHandler);\n this.#uncaughtExceptionHandler = undefined;\n }\n }\n\n // Bit of a hacky way to grab the lifecycle services, potentially find a nicer way to do this\n async #getRootLifecycleImpl(): Promise<\n RootLifecycleService & {\n startup(): Promise<void>;\n beforeShutdown(): Promise<void>;\n shutdown(): Promise<void>;\n }\n > {\n const lifecycleService = await this.#serviceRegistry.get(\n coreServices.rootLifecycle,\n 'root',\n );\n\n const service = lifecycleService as any;\n if (\n service &&\n typeof service.startup === 'function' &&\n typeof service.shutdown === 'function'\n ) {\n return service;\n }\n\n throw new Error('Unexpected root lifecycle service implementation');\n }\n\n async #getPluginLifecycleImpl(\n pluginId: string,\n ): Promise<\n LifecycleService & { startup(): Promise<void>; shutdown(): Promise<void> }\n > {\n const lifecycleService = await this.#serviceRegistry.get(\n coreServices.lifecycle,\n pluginId,\n );\n\n const service = lifecycleService as any;\n if (\n service &&\n typeof service.startup === 'function' &&\n typeof service.shutdown === 'function'\n ) {\n return service;\n }\n\n throw new Error('Unexpected plugin lifecycle service implementation');\n }\n\n async #applyBackendFeatureLoaders(loaders: InternalBackendFeatureLoader[]) {\n const servicesAddedByLoaders = new Map<\n string,\n InternalBackendFeatureLoader\n >();\n\n for (const loader of loaders) {\n const deps = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(loader.deps ?? {})) {\n if (ref.scope !== 'root') {\n throw new Error(\n `Feature loaders can only depend on root scoped services, but '${name}' is scoped to '${ref.scope}'. Offending loader is ${loader.description}`,\n );\n }\n const impl = await this.#serviceRegistry.get(\n ref as ServiceRef<unknown>,\n 'root',\n );\n if (impl) {\n deps.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No service available for the following ref(s): ${missing}, depended on by feature loader ${loader.description}`,\n );\n }\n\n const result = await loader\n .loader(Object.fromEntries(deps))\n .then(features => features.map(unwrapFeature))\n .catch(error => {\n throw new ForwardedError(\n `Feature loader ${loader.description} failed`,\n error,\n );\n });\n\n let didAddServiceFactory = false;\n const newLoaders = new Array<InternalBackendFeatureLoader>();\n\n for await (const feature of result) {\n if (isBackendFeatureLoader(feature)) {\n newLoaders.push(feature);\n } else {\n // This block makes sure that feature loaders do not provide duplicate\n // implementations for the same service, but at the same time allows\n // service factories provided by feature loaders to be overridden by\n // ones that are explicitly installed with backend.add(serviceFactory).\n //\n // If a factory has already been explicitly installed, the service\n // factory provided by the loader will simply be ignored.\n if (isServiceFactory(feature) && !feature.service.multiton) {\n const conflictingLoader = servicesAddedByLoaders.get(\n feature.service.id,\n );\n if (conflictingLoader) {\n throw new Error(\n `Duplicate service implementations provided for ${feature.service.id} by both feature loader ${loader.description} and feature loader ${conflictingLoader.description}`,\n );\n }\n\n // Check that this service wasn't already explicitly added by backend.add(serviceFactory)\n if (!this.#serviceRegistry.hasBeenAdded(feature.service)) {\n didAddServiceFactory = true;\n servicesAddedByLoaders.set(feature.service.id, loader);\n this.#addFeature(feature);\n }\n } else {\n this.#addFeature(feature);\n }\n }\n }\n\n // Every time we add a new service factory we need to make sure that we don't have circular dependencies\n if (didAddServiceFactory) {\n this.#serviceRegistry.checkForCircularDeps();\n }\n\n // Apply loaders recursively, depth-first\n if (newLoaders.length > 0) {\n await this.#applyBackendFeatureLoaders(newLoaders);\n }\n }\n }\n}\n\nfunction toInternalBackendFeature(\n feature: BackendFeature,\n): InternalBackendFeature {\n if (feature.$$type !== '@backstage/BackendFeature') {\n throw new Error(`Invalid BackendFeature, bad type '${feature.$$type}'`);\n }\n const internal = feature as InternalBackendFeature;\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid BackendFeature, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\nfunction isServiceFactory(\n feature: BackendFeature,\n): feature is InternalServiceFactory {\n const internal = toInternalBackendFeature(feature);\n if (internal.featureType === 'service') {\n return true;\n }\n // Backwards compatibility for v1 registrations that use duck typing\n return 'service' in internal;\n}\n\nfunction isBackendRegistrations(\n feature: BackendFeature,\n): feature is InternalBackendRegistrations {\n const internal = toInternalBackendFeature(feature);\n if (internal.featureType === 'registrations') {\n return true;\n }\n // Backwards compatibility for v1 registrations that use duck typing\n return 'getRegistrations' in internal;\n}\n\nfunction isBackendFeatureLoader(\n feature: BackendFeature,\n): feature is InternalBackendFeatureLoader {\n return toInternalBackendFeature(feature).featureType === 'loader';\n}\n"],"names":["createServiceFactory","coreServices","deepFreeze","ServiceRegistry","rootLogger","createInitializationResultCollector","createAllowBootFailurePredicate","DependencyGraph","ConflictError","assertError","lifecycleService","ForwardedError","BackendStartupError","unwrapFeature"],"mappings":";;;;;;;;;;;AA2DA,MAAM,gBAAA,GAAmB,IAAK,MAAM,gBAAA,CAAiB;AAAA,EACnD,WAAA,GAAc,KAAA;AAAA,EACd,UAAA,uBAAiB,GAAA,EAAwB;AAAA,EAEzC,SAAS,QAAA,EAA8B;AACrC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACrB,MAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AAEnB,MAAA,OAAA,CAAQ,WAAA,CAAY,SAAA,EAAW,IAAA,CAAK,YAAY,CAAA;AAChD,MAAA,OAAA,CAAQ,WAAA,CAAY,QAAA,EAAU,IAAA,CAAK,YAAY,CAAA;AAC/C,MAAA,OAAA,CAAQ,WAAA,CAAY,YAAA,EAAc,IAAA,CAAK,YAAY,CAAA;AAAA,IACrD;AAEA,IAAA,IAAA,CAAK,UAAA,CAAW,IAAI,QAAQ,CAAA;AAAA,EAC9B;AAAA,EAEA,WAAW,QAAA,EAA8B;AACvC,IAAA,IAAA,CAAK,UAAA,CAAW,OAAO,QAAQ,CAAA;AAAA,EACjC;AAAA,EAEA,eAAe,YAAY;AACzB,IAAA,IAAI;AACF,MAAA,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AACzC,EAAA,MAAM,QAAA,GAAW,yBAAyB,OAAO,CAAA;AACjD,EAAA,IAAI,QAAA,CAAS,gBAAgB,eAAA,EAAiB;AAC5C,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,kBAAA,IAAsB,QAAA;AAC/B;AAEA,SAAS,uBACP,OAAA,EACyC;AACzC,EAAA,OAAO,wBAAA,CAAyB,OAAO,CAAA,CAAE,WAAA,KAAgB,QAAA;AAC3D;;;;"}
|
|
1
|
+
{"version":3,"file":"BackendInitializer.cjs.js","sources":["../../src/wiring/BackendInitializer.ts"],"sourcesContent":["/*\n * Copyright 2022 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 */\n\nimport {\n BackendFeature,\n ExtensionPoint,\n coreServices,\n ServiceRef,\n ServiceFactory,\n LifecycleService,\n RootLifecycleService,\n createServiceFactory,\n ExtensionPointFactoryContext,\n} from '@backstage/backend-plugin-api';\nimport { ServiceOrExtensionPoint } from './types';\n// Direct internal import to avoid duplication\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type {\n InternalBackendFeature,\n InternalBackendFeatureLoader,\n InternalBackendRegistrations,\n} from '../../../backend-plugin-api/src/wiring/types';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type { InternalServiceFactory } from '../../../backend-plugin-api/src/services/system/types';\nimport { ForwardedError, ConflictError, assertError } from '@backstage/errors';\nimport { DependencyGraph } from '../lib/DependencyGraph';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { createInitializationResultCollector } from './createInitializationResultCollector';\nimport { deepFreeze, unwrapFeature } from './helpers';\nimport type { RootInstanceMetadataServicePluginInfo } from '@backstage/backend-plugin-api';\nimport { BackendStartupResult } from './types';\nimport { BackendStartupError } from './BackendStartupError';\nimport { createAllowBootFailurePredicate } from './createAllowBootFailurePredicate';\n\nexport interface BackendRegisterInit {\n consumes: Set<ServiceOrExtensionPoint>;\n provides: Set<ServiceOrExtensionPoint>;\n init: {\n deps: { [name: string]: ServiceOrExtensionPoint };\n func: (deps: { [name: string]: unknown }) => Promise<void>;\n };\n}\n\n/**\n * A registry of backend instances, used to manage process shutdown hooks across all instances.\n */\nconst instanceRegistry = new (class InstanceRegistry {\n #registered = false;\n #instances = new Set<BackendInitializer>();\n\n register(instance: BackendInitializer) {\n if (!this.#registered) {\n this.#registered = true;\n\n process.addListener('SIGTERM', this.#exitHandler);\n process.addListener('SIGINT', this.#exitHandler);\n process.addListener('beforeExit', this.#exitHandler);\n }\n\n this.#instances.add(instance);\n }\n\n unregister(instance: BackendInitializer) {\n this.#instances.delete(instance);\n }\n\n #exitHandler = async () => {\n try {\n const results = await Promise.allSettled(\n Array.from(this.#instances).map(b => b.stop()),\n );\n const errors = results.flatMap(r =>\n r.status === 'rejected' ? [r.reason] : [],\n );\n\n if (errors.length > 0) {\n for (const error of errors) {\n console.error(error);\n }\n process.exit(1);\n } else {\n process.exit(0);\n }\n } catch (error) {\n console.error(error);\n process.exit(1);\n }\n };\n})();\n\nfunction createRootInstanceMetadataServiceFactory(\n rawRegistrations: InternalBackendRegistrations[],\n) {\n const installedPlugins: Map<string, RootInstanceMetadataServicePluginInfo> =\n new Map();\n const registrations = rawRegistrations\n .filter(registration => registration.featureType === 'registrations')\n .flatMap(registration => registration.getRegistrations());\n const plugins = registrations.filter(\n registration =>\n registration.type === 'plugin' || registration.type === 'plugin-v1.1',\n );\n const modules = registrations.filter(\n registration =>\n registration.type === 'module' || registration.type === 'module-v1.1',\n );\n for (const plugin of plugins) {\n const { pluginId } = plugin;\n if (!installedPlugins.get(pluginId)) {\n installedPlugins.set(pluginId, {\n pluginId,\n modules: [],\n });\n }\n }\n for (const module of modules) {\n const { pluginId, moduleId } = module;\n const installedPlugin = installedPlugins.get(pluginId);\n if (installedPlugin) {\n (installedPlugin.modules as Array<{ moduleId: string }>).push({\n moduleId,\n });\n }\n }\n\n return createServiceFactory({\n service: coreServices.rootInstanceMetadata,\n deps: {},\n factory: async () => {\n const readonlyInstalledPlugins = deepFreeze([\n ...installedPlugins.values(),\n ]);\n const instanceMetadata = {\n getInstalledPlugins: () => Promise.resolve(readonlyInstalledPlugins),\n };\n\n return instanceMetadata;\n },\n });\n}\n\nexport class BackendInitializer {\n #startPromise?: Promise<{ result: BackendStartupResult }>;\n #stopPromise?: Promise<void>;\n #registrations = new Array<InternalBackendRegistrations>();\n #extensionPoints = new Map<\n string,\n {\n pluginId: string;\n factory: (context: ExtensionPointFactoryContext) => unknown;\n }\n >();\n #serviceRegistry: ServiceRegistry;\n #registeredFeatures = new Array<Promise<BackendFeature>>();\n #registeredFeatureLoaders = new Array<InternalBackendFeatureLoader>();\n #unhandledRejectionHandler?: (reason: Error) => void;\n #uncaughtExceptionHandler?: (error: Error) => void;\n\n constructor(defaultApiFactories: ServiceFactory[]) {\n this.#serviceRegistry = ServiceRegistry.create([...defaultApiFactories]);\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n resultCollector: ReturnType<typeof createInitializationResultCollector>,\n pluginId: string,\n moduleId?: string,\n ) {\n const result = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(deps)) {\n const ep = this.#extensionPoints.get(ref.id);\n if (ep) {\n if (ep.pluginId !== pluginId) {\n throw new Error(\n `Illegal dependency: Module '${moduleId}' for plugin '${pluginId}' attempted to depend on extension point '${ref.id}' for plugin '${ep.pluginId}'. Extension points can only be used within their plugin's scope.`,\n );\n }\n if (!moduleId) {\n throw new Error(\n `Rejected dependency on extension point ${ref.id} from outside of a module`,\n );\n }\n result.set(\n name,\n ep.factory({\n reportModuleStartupFailure: ({ error }) => {\n resultCollector.amendPluginModuleResult(\n pluginId,\n moduleId,\n error,\n );\n },\n }),\n );\n } else {\n const impl = await this.#serviceRegistry.get(\n ref as ServiceRef<unknown>,\n pluginId,\n );\n if (impl) {\n result.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n const target = moduleId\n ? `module '${moduleId}' for plugin '${pluginId}'`\n : `plugin '${pluginId}'`;\n throw new Error(\n `Service or extension point dependencies of ${target} are missing for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add(feature: BackendFeature | Promise<BackendFeature>) {\n if (this.#startPromise) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#registeredFeatures.push(Promise.resolve(feature));\n }\n\n #addFeature(feature: BackendFeature) {\n if (isServiceFactory(feature)) {\n this.#serviceRegistry.add(feature);\n } else if (isBackendFeatureLoader(feature)) {\n this.#registeredFeatureLoaders.push(feature);\n } else if (isBackendRegistrations(feature)) {\n this.#registrations.push(feature);\n } else {\n throw new Error(\n `Failed to add feature, invalid feature ${JSON.stringify(feature)}`,\n );\n }\n }\n\n async start(): Promise<{ result: BackendStartupResult }> {\n if (this.#startPromise) {\n throw new Error('Backend has already started');\n }\n if (this.#stopPromise) {\n throw new Error('Backend has already stopped');\n }\n\n instanceRegistry.register(this);\n\n this.#startPromise = this.#doStart();\n return await this.#startPromise;\n }\n\n async #doStart(): Promise<{ result: BackendStartupResult }> {\n this.#serviceRegistry.checkForCircularDeps();\n\n for (const feature of this.#registeredFeatures) {\n this.#addFeature(await feature);\n }\n\n await this.#applyBackendFeatureLoaders(this.#registeredFeatureLoaders);\n\n this.#serviceRegistry.add(\n createRootInstanceMetadataServiceFactory(this.#registrations),\n );\n\n // This makes sure that any uncaught errors or unhandled rejections are\n // caught and logged, rather than terminating the process. We register these\n // as early as possible while still using the root logger service, the\n // tradeoff that if there are any unhandled errors as part of the that\n // instationation, it will cause the process to crash. If there are multiple\n // backend instances, each instance will log the error, because we can't\n // determine which instance the error came from.\n if (process.env.NODE_ENV !== 'test') {\n const rootLogger = await this.#serviceRegistry.get(\n coreServices.rootLogger,\n 'root',\n );\n this.#unhandledRejectionHandler = (reason: Error) => {\n rootLogger\n ?.child({ type: 'unhandledRejection' })\n ?.error('Unhandled rejection', reason);\n };\n this.#uncaughtExceptionHandler = (error: Error) => {\n rootLogger\n ?.child({ type: 'uncaughtException' })\n ?.error('Uncaught exception', error);\n };\n process.on('unhandledRejection', this.#unhandledRejectionHandler);\n process.on('uncaughtException', this.#uncaughtExceptionHandler);\n }\n\n // Initialize all root scoped services\n await this.#serviceRegistry.initializeEagerServicesWithScope('root');\n\n const rootConfig = await this.#serviceRegistry.get(\n coreServices.rootConfig,\n 'root',\n );\n const rootLogger = await this.#serviceRegistry.get(\n coreServices.rootLogger,\n 'root',\n );\n\n const allRegistrations = this.#registrations.flatMap(f =>\n f.getRegistrations(),\n );\n\n const allPluginIds = [\n ...new Set(\n allRegistrations.flatMap(r =>\n 'pluginId' in r && typeof r.pluginId === 'string' ? [r.pluginId] : [],\n ),\n ),\n ];\n\n const resultCollector = createInitializationResultCollector({\n pluginIds: allPluginIds,\n logger: rootLogger,\n allowBootFailurePredicate: createAllowBootFailurePredicate(rootConfig),\n });\n\n const { pluginInits, moduleInits } = this.#enumerateRegistrations(\n allRegistrations,\n resultCollector,\n );\n\n // All plugins are initialized in parallel\n await Promise.all(\n [...pluginInits.keys()].map(async pluginId => {\n try {\n // Initialize all eager services\n await this.#serviceRegistry.initializeEagerServicesWithScope(\n 'plugin',\n pluginId,\n );\n\n // Modules are initialized before plugins, so that they can provide extension to the plugin\n const modules = moduleInits.get(pluginId);\n if (modules) {\n const tree = DependencyGraph.fromIterable(\n Array.from(modules).map(([moduleId, moduleInit]) => ({\n value: { moduleId, moduleInit },\n // Relationships are reversed at this point since we're only interested in the extension points.\n // If a modules provides extension point A we want it to be initialized AFTER all modules\n // that depend on extension point A, so that they can provide their extensions.\n consumes: Array.from(moduleInit.provides).map(p => p.id),\n provides: Array.from(moduleInit.consumes).map(c => c.id),\n })),\n );\n const circular = tree.detectCircularDependency();\n if (circular) {\n throw new ConflictError(\n `Circular dependency detected for modules of plugin '${pluginId}', ${circular\n .map(({ moduleId }) => `'${moduleId}'`)\n .join(' -> ')}`,\n );\n }\n await tree.parallelTopologicalTraversal(\n async ({ moduleId, moduleInit }) => {\n try {\n const moduleDeps = await this.#getInitDeps(\n moduleInit.init.deps,\n resultCollector,\n pluginId,\n moduleId,\n );\n await moduleInit.init.func(moduleDeps);\n resultCollector.onPluginModuleResult(pluginId, moduleId);\n } catch (error: unknown) {\n assertError(error);\n resultCollector.onPluginModuleResult(\n pluginId,\n moduleId,\n error,\n );\n }\n },\n );\n }\n\n // Once all modules have been initialized, we can initialize the plugin itself\n const pluginInit = pluginInits.get(pluginId);\n // We allow modules to be installed without the accompanying plugin, so the plugin may not exist\n if (pluginInit) {\n const pluginDeps = await this.#getInitDeps(\n pluginInit.init.deps,\n resultCollector,\n pluginId,\n );\n await pluginInit.init.func(pluginDeps);\n }\n\n resultCollector.onPluginResult(pluginId);\n\n // Once the plugin and all modules have been initialized, we can signal that the plugin has stared up successfully\n const lifecycleService = await this.#getPluginLifecycleImpl(pluginId);\n await lifecycleService.startup();\n } catch (error: unknown) {\n assertError(error);\n resultCollector.onPluginResult(pluginId, error);\n }\n }),\n ).catch(error => {\n throw new ForwardedError(\n 'Unexpected uncaught backend startup error',\n error,\n );\n });\n\n const result = resultCollector.finalize();\n if (result.outcome === 'failure') {\n throw new BackendStartupError(result);\n }\n\n // Once all plugins and modules have been initialized, we can signal that the backend has started up successfully\n const lifecycleService = await this.#getRootLifecycleImpl();\n await lifecycleService.startup();\n\n return { result };\n }\n\n #enumerateRegistrations(\n allRegistrations: ReturnType<\n InternalBackendRegistrations['getRegistrations']\n >,\n resultCollector: ReturnType<typeof createInitializationResultCollector>,\n ): {\n pluginInits: Map<string, BackendRegisterInit>;\n moduleInits: Map<string, Map<string, BackendRegisterInit>>;\n } {\n const pluginInits = new Map<string, BackendRegisterInit>();\n const moduleInits = new Map<string, Map<string, BackendRegisterInit>>();\n\n for (const r of allRegistrations) {\n const addedExtensionPointIds: string[] = [];\n try {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n if (r.type === 'plugin' || r.type === 'module') {\n // Handle v1 format: Array<readonly [ExtensionPoint<unknown>, unknown]>\n for (const [extRef, extImpl] of r.extensionPoints) {\n if (this.#extensionPoints.has(extRef.id)) {\n throw new Error(\n `ExtensionPoint with ID '${extRef.id}' is already registered`,\n );\n }\n this.#extensionPoints.set(extRef.id, {\n pluginId: r.pluginId,\n factory: () => extImpl,\n });\n addedExtensionPointIds.push(extRef.id);\n provides.add(extRef);\n }\n } else if (r.type === 'plugin-v1.1' || r.type === 'module-v1.1') {\n // Handle v1.1 format: Array<ExtensionPointRegistration>\n for (const extReg of r.extensionPoints) {\n if (this.#extensionPoints.has(extReg.extensionPoint.id)) {\n throw new Error(\n `ExtensionPoint with ID '${extReg.extensionPoint.id}' is already registered`,\n );\n }\n this.#extensionPoints.set(extReg.extensionPoint.id, {\n pluginId: r.pluginId,\n factory: extReg.factory,\n });\n addedExtensionPointIds.push(extReg.extensionPoint.id);\n provides.add(extReg.extensionPoint);\n }\n }\n\n if (r.type === 'plugin' || r.type === 'plugin-v1.1') {\n if (pluginInits.has(r.pluginId)) {\n throw new Error(`Plugin '${r.pluginId}' is already registered`);\n }\n pluginInits.set(r.pluginId, {\n provides,\n consumes: new Set(Object.values(r.init.deps)),\n init: r.init,\n });\n } else if (r.type === 'module' || r.type === 'module-v1.1') {\n let modules = moduleInits.get(r.pluginId);\n if (!modules) {\n modules = new Map();\n moduleInits.set(r.pluginId, modules);\n }\n if (modules.has(r.moduleId)) {\n throw new Error(\n `Module '${r.moduleId}' for plugin '${r.pluginId}' is already registered`,\n );\n }\n modules.set(r.moduleId, {\n provides,\n consumes: new Set(Object.values(r.init.deps)),\n init: r.init,\n });\n } else {\n throw new Error(`Invalid registration type '${(r as any).type}'`);\n }\n } catch (error: unknown) {\n assertError(error);\n // Clean up partially registered extension points\n for (const id of addedExtensionPointIds) {\n this.#extensionPoints.delete(id);\n }\n if ('pluginId' in r && 'moduleId' in r) {\n resultCollector.onPluginModuleResult(r.pluginId, r.moduleId, error);\n } else if ('pluginId' in r) {\n pluginInits.delete(r.pluginId);\n moduleInits.delete(r.pluginId);\n resultCollector.onPluginResult(r.pluginId, error);\n } else {\n throw error;\n }\n }\n }\n\n return { pluginInits, moduleInits };\n }\n\n // It's fine to call .stop() multiple times, which for example can happen with manual stop + process exit\n async stop(): Promise<void> {\n instanceRegistry.unregister(this);\n\n if (!this.#stopPromise) {\n this.#stopPromise = this.#doStop();\n }\n await this.#stopPromise;\n }\n\n async #doStop(): Promise<void> {\n if (!this.#startPromise) {\n return;\n }\n\n try {\n await this.#startPromise;\n } catch (error) {\n // The startup failed, but we may still want to do cleanup so we continue silently\n }\n\n const rootLifecycleService = await this.#getRootLifecycleImpl();\n\n // Root services like the health one need to immediately be notified of the shutdown\n await rootLifecycleService.beforeShutdown();\n\n // Get all plugins.\n const allPlugins = new Set<string>();\n for (const feature of this.#registrations) {\n for (const r of feature.getRegistrations()) {\n if (r.type === 'plugin' || r.type === 'plugin-v1.1') {\n allPlugins.add(r.pluginId);\n }\n }\n }\n\n // Iterate through all plugins and run their shutdown hooks.\n await Promise.allSettled(\n [...allPlugins].map(async pluginId => {\n const lifecycleService = await this.#getPluginLifecycleImpl(pluginId);\n await lifecycleService.shutdown();\n }),\n );\n\n // Once all plugin shutdown hooks are done, run root shutdown hooks.\n await rootLifecycleService.shutdown();\n\n // Clean up process event listeners to prevent memory leaks and duplicate logging\n if (this.#unhandledRejectionHandler) {\n process.off('unhandledRejection', this.#unhandledRejectionHandler);\n this.#unhandledRejectionHandler = undefined;\n }\n if (this.#uncaughtExceptionHandler) {\n process.off('uncaughtException', this.#uncaughtExceptionHandler);\n this.#uncaughtExceptionHandler = undefined;\n }\n }\n\n // Bit of a hacky way to grab the lifecycle services, potentially find a nicer way to do this\n async #getRootLifecycleImpl(): Promise<\n RootLifecycleService & {\n startup(): Promise<void>;\n beforeShutdown(): Promise<void>;\n shutdown(): Promise<void>;\n }\n > {\n const lifecycleService = await this.#serviceRegistry.get(\n coreServices.rootLifecycle,\n 'root',\n );\n\n const service = lifecycleService as any;\n if (\n service &&\n typeof service.startup === 'function' &&\n typeof service.shutdown === 'function'\n ) {\n return service;\n }\n\n throw new Error('Unexpected root lifecycle service implementation');\n }\n\n async #getPluginLifecycleImpl(\n pluginId: string,\n ): Promise<\n LifecycleService & { startup(): Promise<void>; shutdown(): Promise<void> }\n > {\n const lifecycleService = await this.#serviceRegistry.get(\n coreServices.lifecycle,\n pluginId,\n );\n\n const service = lifecycleService as any;\n if (\n service &&\n typeof service.startup === 'function' &&\n typeof service.shutdown === 'function'\n ) {\n return service;\n }\n\n throw new Error('Unexpected plugin lifecycle service implementation');\n }\n\n async #applyBackendFeatureLoaders(loaders: InternalBackendFeatureLoader[]) {\n const servicesAddedByLoaders = new Map<\n string,\n InternalBackendFeatureLoader\n >();\n\n for (const loader of loaders) {\n const deps = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(loader.deps ?? {})) {\n if (ref.scope !== 'root') {\n throw new Error(\n `Feature loaders can only depend on root scoped services, but '${name}' is scoped to '${ref.scope}'. Offending loader is ${loader.description}`,\n );\n }\n const impl = await this.#serviceRegistry.get(\n ref as ServiceRef<unknown>,\n 'root',\n );\n if (impl) {\n deps.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No service available for the following ref(s): ${missing}, depended on by feature loader ${loader.description}`,\n );\n }\n\n const result = await loader\n .loader(Object.fromEntries(deps))\n .then(features => features.map(unwrapFeature))\n .catch(error => {\n throw new ForwardedError(\n `Feature loader ${loader.description} failed`,\n error,\n );\n });\n\n let didAddServiceFactory = false;\n const newLoaders = new Array<InternalBackendFeatureLoader>();\n\n for await (const feature of result) {\n if (isBackendFeatureLoader(feature)) {\n newLoaders.push(feature);\n } else {\n // This block makes sure that feature loaders do not provide duplicate\n // implementations for the same service, but at the same time allows\n // service factories provided by feature loaders to be overridden by\n // ones that are explicitly installed with backend.add(serviceFactory).\n //\n // If a factory has already been explicitly installed, the service\n // factory provided by the loader will simply be ignored.\n if (isServiceFactory(feature) && !feature.service.multiton) {\n const conflictingLoader = servicesAddedByLoaders.get(\n feature.service.id,\n );\n if (conflictingLoader) {\n throw new Error(\n `Duplicate service implementations provided for ${feature.service.id} by both feature loader ${loader.description} and feature loader ${conflictingLoader.description}`,\n );\n }\n\n // Check that this service wasn't already explicitly added by backend.add(serviceFactory)\n if (!this.#serviceRegistry.hasBeenAdded(feature.service)) {\n didAddServiceFactory = true;\n servicesAddedByLoaders.set(feature.service.id, loader);\n this.#addFeature(feature);\n }\n } else {\n this.#addFeature(feature);\n }\n }\n }\n\n // Every time we add a new service factory we need to make sure that we don't have circular dependencies\n if (didAddServiceFactory) {\n this.#serviceRegistry.checkForCircularDeps();\n }\n\n // Apply loaders recursively, depth-first\n if (newLoaders.length > 0) {\n await this.#applyBackendFeatureLoaders(newLoaders);\n }\n }\n }\n}\n\nfunction toInternalBackendFeature(\n feature: BackendFeature,\n): InternalBackendFeature {\n if (feature.$$type !== '@backstage/BackendFeature') {\n throw new Error(`Invalid BackendFeature, bad type '${feature.$$type}'`);\n }\n const internal = feature as InternalBackendFeature;\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid BackendFeature, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\nfunction isServiceFactory(\n feature: BackendFeature,\n): feature is InternalServiceFactory {\n const internal = toInternalBackendFeature(feature);\n if (internal.featureType === 'service') {\n return true;\n }\n // Backwards compatibility for v1 registrations that use duck typing\n return 'service' in internal;\n}\n\nfunction isBackendRegistrations(\n feature: BackendFeature,\n): feature is InternalBackendRegistrations {\n const internal = toInternalBackendFeature(feature);\n if (internal.featureType === 'registrations') {\n return true;\n }\n // Backwards compatibility for v1 registrations that use duck typing\n return 'getRegistrations' in internal;\n}\n\nfunction isBackendFeatureLoader(\n feature: BackendFeature,\n): feature is InternalBackendFeatureLoader {\n return toInternalBackendFeature(feature).featureType === 'loader';\n}\n"],"names":["createServiceFactory","coreServices","deepFreeze","ServiceRegistry","rootLogger","createInitializationResultCollector","createAllowBootFailurePredicate","DependencyGraph","ConflictError","assertError","lifecycleService","ForwardedError","BackendStartupError","unwrapFeature"],"mappings":";;;;;;;;;;;AA2DA,MAAM,gBAAA,GAAmB,IAAK,MAAM,gBAAA,CAAiB;AAAA,EACnD,WAAA,GAAc,KAAA;AAAA,EACd,UAAA,uBAAiB,GAAA,EAAwB;AAAA,EAEzC,SAAS,QAAA,EAA8B;AACrC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACrB,MAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AAEnB,MAAA,OAAA,CAAQ,WAAA,CAAY,SAAA,EAAW,IAAA,CAAK,YAAY,CAAA;AAChD,MAAA,OAAA,CAAQ,WAAA,CAAY,QAAA,EAAU,IAAA,CAAK,YAAY,CAAA;AAC/C,MAAA,OAAA,CAAQ,WAAA,CAAY,YAAA,EAAc,IAAA,CAAK,YAAY,CAAA;AAAA,IACrD;AAEA,IAAA,IAAA,CAAK,UAAA,CAAW,IAAI,QAAQ,CAAA;AAAA,EAC9B;AAAA,EAEA,WAAW,QAAA,EAA8B;AACvC,IAAA,IAAA,CAAK,UAAA,CAAW,OAAO,QAAQ,CAAA;AAAA,EACjC;AAAA,EAEA,eAAe,YAAY;AACzB,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,MAAM,OAAA,CAAQ,UAAA;AAAA,QAC5B,KAAA,CAAM,KAAK,IAAA,CAAK,UAAU,EAAE,GAAA,CAAI,CAAA,CAAA,KAAK,CAA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AAS,gBAAgB,eAAA,EAAiB;AAC5C,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,kBAAA,IAAsB,QAAA;AAC/B;AAEA,SAAS,uBACP,OAAA,EACyC;AACzC,EAAA,OAAO,wBAAA,CAAyB,OAAO,CAAA,CAAE,WAAA,KAAgB,QAAA;AAC3D;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-app-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-next.1",
|
|
4
4
|
"description": "Core API used by Backstage backend apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library"
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"test": "backstage-cli package test"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@backstage/backend-plugin-api": "
|
|
54
|
-
"@backstage/config": "
|
|
55
|
-
"@backstage/errors": "
|
|
53
|
+
"@backstage/backend-plugin-api": "1.8.0-next.1",
|
|
54
|
+
"@backstage/config": "1.3.6",
|
|
55
|
+
"@backstage/errors": "1.2.7"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@backstage/backend-defaults": "
|
|
59
|
-
"@backstage/backend-test-utils": "
|
|
60
|
-
"@backstage/cli": "
|
|
58
|
+
"@backstage/backend-defaults": "0.16.0-next.2",
|
|
59
|
+
"@backstage/backend-test-utils": "1.11.1-next.2",
|
|
60
|
+
"@backstage/cli": "0.36.0-next.2"
|
|
61
61
|
},
|
|
62
62
|
"configSchema": "config.d.ts"
|
|
63
63
|
}
|