From 0019cea06f660b3d685f8fe949e14425cb5b8961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 26 Jan 2022 14:08:53 +0100 Subject: [PATCH] clarify that providers should be started AFTER the catalog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .../features/software-catalog/external-integrations.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/features/software-catalog/external-integrations.md b/docs/features/software-catalog/external-integrations.md index 6a786d84d0..b14fd732d7 100644 --- a/docs/features/software-catalog/external-integrations.md +++ b/docs/features/software-catalog/external-integrations.md @@ -225,7 +225,7 @@ This may seem complex, but is a vital mechanism for ensuring that users aren't permitted to do "rogue" takeovers of already registered entities that belong to others. -## Installing the Provider +### Installing the Provider You should now be able to add this class to your backend in `packages/backend/src/plugins/catalog.ts`: @@ -242,10 +242,12 @@ You should now be able to add this class to your backend in + const frobs = new FrobsProvider('production', env.reader); + builder.addEntityProvider(frobs); + const { processingEngine, router } = await builder.build(); + await processingEngine.start(); + + await env.scheduler.scheduleTask({ + id: 'run_frobs_refresh', + fn: async () => { await frobs.run(); }, -+ initialDelay: Duration.fromObject({ seconds: 10 }), + frequency: Duration.fromObject({ minutes: 30 }), + timeout: Duration.fromObject({ minutes: 10 }), + }); @@ -253,7 +255,9 @@ You should now be able to add this class to your backend in Note that we used the builtin scheduler facility to regularly call the `run` method of the provider, in this example. It is a suitable driver for this -particular type of recurring task. +particular type of recurring task. We placed the scheduling after the actual +construction and startup phase of the rest of the catalog, because at that point +the `connect` call has been made to the provider. Start up the backend - it should now start reading from the previously registered location and you'll see your entities start to appear in Backstage.