From 1acd16ecbea406bded68cbc194d1e99ff0306ee5 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 10 Oct 2024 09:41:07 +0200 Subject: [PATCH] feat: added the ability to disable catalog processing Signed-off-by: blam --- plugins/catalog-backend/config.d.ts | 16 +++++++++++++++- .../catalog-backend/src/service/CatalogPlugin.ts | 12 ++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/plugins/catalog-backend/config.d.ts b/plugins/catalog-backend/config.d.ts index 8bab83d4b4..57b31305c4 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: @@ -186,5 +185,20 @@ export interface Config { * housing catalog-info files. */ processingInterval?: HumanDuration; + /** + * If the processing engine should be started or not, defaults to true. + * @remarks + * + * Example: + * + * ```yaml + * catalog: + * processingInterval: false + * ``` + * + * 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/CatalogPlugin.ts b/plugins/catalog-backend/src/service/CatalogPlugin.ts index e36e4e1333..b39898afb2 100644 --- a/plugins/catalog-backend/src/service/CatalogPlugin.ts +++ b/plugins/catalog-backend/src/service/CatalogPlugin.ts @@ -42,6 +42,7 @@ import { import { merge } from 'lodash'; import { Permission } from '@backstage/plugin-permission-common'; import { ForwardedError } from '@backstage/errors'; +import { constrainedMemory } from 'node:process'; class CatalogLocationsExtensionPointImpl implements CatalogLocationsExtensionPoint @@ -301,10 +302,13 @@ export const catalogPlugin = createBackendPlugin({ const { processingEngine, router } = await builder.build(); - lifecycle.addStartupHook(async () => { - await processingEngine.start(); - }); - lifecycle.addShutdownHook(() => processingEngine.stop()); + if (config.getOptionalBoolean('catalog.processingEnabled') ?? true) { + lifecycle.addStartupHook(async () => { + await processingEngine.start(); + }); + lifecycle.addShutdownHook(() => processingEngine.stop()); + } + httpRouter.use(router); }, });