@backstage/backend-plugin-api
Version:
Core API used by Backstage backend plugins
35 lines (31 loc) • 1.19 kB
JavaScript
;
var config = require('@backstage/config');
function readFrequency(config$1, key) {
const value = config$1.get(key);
if (typeof value === "object" && value.cron) {
return value;
}
if (typeof value === "object" && value.trigger === "manual") {
return { trigger: "manual" };
}
return config.readDurationFromConfig(config$1, { key });
}
function readSchedulerServiceTaskScheduleDefinitionFromConfig(config$1) {
const frequency = readFrequency(config$1, "frequency");
const timeout = config.readDurationFromConfig(config$1, { key: "timeout" });
const initialDelay = config$1.has("initialDelay") ? config.readDurationFromConfig(config$1, { key: "initialDelay" }) : void 0;
const scope = config$1.getOptionalString("scope");
if (scope && !["global", "local"].includes(scope)) {
throw new Error(
`Only "global" or "local" are allowed for TaskScheduleDefinition.scope, but got: ${scope}`
);
}
return {
frequency,
timeout,
initialDelay,
scope
};
}
exports.readSchedulerServiceTaskScheduleDefinitionFromConfig = readSchedulerServiceTaskScheduleDefinitionFromConfig;
//# sourceMappingURL=SchedulerService.cjs.js.map