feat(catalog-backend): Added doc and review fixes

Signed-off-by: Łukasz Jernaś <lukasz.jernas@allegro.com>
This commit is contained in:
Łukasz Jernaś
2024-10-09 17:52:36 +02:00
parent c1f9764004
commit 718ce10f57
3 changed files with 51 additions and 13 deletions
+2 -2
View File
@@ -157,9 +157,9 @@ export interface Config {
/** Defer stitching to be performed asynchronously */
mode: 'deferred';
/** Polling interval for tasks in seconds */
pollingInterval?: number;
pollingInterval?: HumanDuration;
/** How long to wait for a stitch to complete before giving up in seconds */
stitchTimeout?: number;
stitchTimeout?: HumanDuration;
};
/**
+16 -8
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Config } from '@backstage/config';
import { Config, readDurationFromConfig } from '@backstage/config';
import { HumanDuration } from '@backstage/types';
/**
@@ -66,15 +66,23 @@ export function stitchingStrategyFromConfig(config: Config): StitchingStrategy {
mode: 'immediate',
};
} else if (strategyMode === 'deferred') {
const pollingInterval =
config.getOptionalNumber('catalog.stitchingStrategy.pollingInterval') ??
1;
const stitchTimeout =
config.getOptionalNumber('catalog.stitchingStrategy.stitchTimeout') ?? 60;
const pollingIntervalKey = 'catalog.stitchingStrategy.pollingInterval';
const stitchTimeoutKey = 'catalog.stitchingStrategy.stitchTimeout';
const pollingInterval = config.has(pollingIntervalKey)
? readDurationFromConfig(config, {
key: pollingIntervalKey,
})
: { seconds: 1 };
const stitchTimeout = config.has(stitchTimeoutKey)
? readDurationFromConfig(config, {
key: stitchTimeoutKey,
})
: { seconds: 60 };
return {
mode: 'deferred',
pollingInterval: { seconds: pollingInterval },
stitchTimeout: { seconds: stitchTimeout },
pollingInterval: pollingInterval,
stitchTimeout: stitchTimeout,
};
}