From e79dcef6e1673197f8c2c3527eb767713b7206a6 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 14 Oct 2024 11:59:04 +0200 Subject: [PATCH] chore: support processingInterval as false Signed-off-by: blam --- .changeset/silly-ligers-tan.md | 2 +- plugins/catalog-backend/config.d.ts | 10 ++++++++-- plugins/catalog-backend/src/service/CatalogBuilder.ts | 9 +++++++++ plugins/catalog-backend/src/service/CatalogPlugin.ts | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.changeset/silly-ligers-tan.md b/.changeset/silly-ligers-tan.md index d5b666a07b..6b9097497d 100644 --- a/.changeset/silly-ligers-tan.md +++ b/.changeset/silly-ligers-tan.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-backend': patch --- -Adds the ability to disable catalog processing with `catalog.processingEnabled` config flag +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 57b31305c4..2f8ec3f230 100644 --- a/plugins/catalog-backend/config.d.ts +++ b/plugins/catalog-backend/config.d.ts @@ -173,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 @@ -184,7 +191,7 @@ export interface Config { * systems that are queried by processors, such as version control systems * housing catalog-info files. */ - processingInterval?: HumanDuration; + processingInterval?: HumanDuration | false; /** * If the processing engine should be started or not, defaults to true. * @remarks @@ -199,6 +206,5 @@ export interface Config { * This will enable or disable the processing of entities in the Catalog. This can be useful * to use with Read Replica deployments of the catalog. */ - processingEnabled?: boolean; }; } 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 b39898afb2..98c99e38dc 100644 --- a/plugins/catalog-backend/src/service/CatalogPlugin.ts +++ b/plugins/catalog-backend/src/service/CatalogPlugin.ts @@ -302,7 +302,7 @@ export const catalogPlugin = createBackendPlugin({ const { processingEngine, router } = await builder.build(); - if (config.getOptionalBoolean('catalog.processingEnabled') ?? true) { + if (config.get('catalog.processingInterval') ?? true) { lifecycle.addStartupHook(async () => { await processingEngine.start(); });