Merge pull request #27067 from backstage/blam/disable-catalog-processing
feat: added the ability to disable catalog processing
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
---
|
||||
|
||||
Adds the ability to disable catalog processing `catalog.processingInterval: false` in `app-config`
|
||||
Vendored
+8
-2
@@ -164,7 +164,6 @@ export interface Config {
|
||||
|
||||
/**
|
||||
* The interval at which the catalog should process its entities.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Example:
|
||||
@@ -174,6 +173,13 @@ export interface Config {
|
||||
* processingInterval: { minutes: 30 }
|
||||
* ```
|
||||
*
|
||||
* or to disabled processing:
|
||||
*
|
||||
* ```yaml
|
||||
* catalog:
|
||||
* processingInterval: false
|
||||
* ```
|
||||
*
|
||||
* Note that this is only a suggested minimum, and the actual interval may
|
||||
* be longer. Internally, the catalog will scale up this number by a small
|
||||
* factor and choose random numbers in that range to spread out the load. If
|
||||
@@ -185,6 +191,6 @@ export interface Config {
|
||||
* systems that are queried by processors, such as version control systems
|
||||
* housing catalog-info files.
|
||||
*/
|
||||
processingInterval?: HumanDuration;
|
||||
processingInterval?: HumanDuration | false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -843,9 +843,18 @@ export class CatalogBuilder {
|
||||
});
|
||||
}
|
||||
|
||||
if (!Boolean(config.get('catalog.processingInterval'))) {
|
||||
return () => {
|
||||
throw new Error(
|
||||
'catalog.processingInterval is set to false, processing is disabled.',
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const duration = readDurationFromConfig(config, {
|
||||
key: processingIntervalKey,
|
||||
});
|
||||
|
||||
const seconds = Math.max(
|
||||
1,
|
||||
Math.round(durationToMilliseconds(duration) / 1000),
|
||||
|
||||
@@ -301,10 +301,13 @@ export const catalogPlugin = createBackendPlugin({
|
||||
|
||||
const { processingEngine, router } = await builder.build();
|
||||
|
||||
lifecycle.addStartupHook(async () => {
|
||||
await processingEngine.start();
|
||||
});
|
||||
lifecycle.addShutdownHook(() => processingEngine.stop());
|
||||
if (config.getOptional('catalog.processingInterval') ?? true) {
|
||||
lifecycle.addStartupHook(async () => {
|
||||
await processingEngine.start();
|
||||
});
|
||||
lifecycle.addShutdownHook(() => processingEngine.stop());
|
||||
}
|
||||
|
||||
httpRouter.use(router);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user