diff --git a/.changeset/silly-ligers-tan.md b/.changeset/silly-ligers-tan.md new file mode 100644 index 0000000000..6b9097497d --- /dev/null +++ b/.changeset/silly-ligers-tan.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Adds the ability to disable catalog processing `catalog.processingInterval: false` in `app-config` diff --git a/plugins/catalog-backend/config.d.ts b/plugins/catalog-backend/config.d.ts index 8bab83d4b4..1ab107ef10 100644 --- a/plugins/catalog-backend/config.d.ts +++ b/plugins/catalog-backend/config.d.ts @@ -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; }; } diff --git a/plugins/catalog-backend/src/service/CatalogBuilder.ts b/plugins/catalog-backend/src/service/CatalogBuilder.ts index c404bfaa0d..31ec40b887 100644 --- a/plugins/catalog-backend/src/service/CatalogBuilder.ts +++ b/plugins/catalog-backend/src/service/CatalogBuilder.ts @@ -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), diff --git a/plugins/catalog-backend/src/service/CatalogPlugin.ts b/plugins/catalog-backend/src/service/CatalogPlugin.ts index e36e4e1333..4da0b612cd 100644 --- a/plugins/catalog-backend/src/service/CatalogPlugin.ts +++ b/plugins/catalog-backend/src/service/CatalogPlugin.ts @@ -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); }, });