Merge pull request #21014 from backstage/rugvip/frequent-worker
backend-tasks: allow tasks to run more frequently than the default work check interval
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-tasks': patch
|
||||
---
|
||||
|
||||
Allow tasks to run more often that the default work check interval, which is 5 seconds.
|
||||
@@ -51,6 +51,15 @@ export class TaskWorker {
|
||||
`Task worker starting: ${this.taskId}, ${JSON.stringify(settings)}`,
|
||||
);
|
||||
|
||||
let workCheckFrequency = this.workCheckFrequency;
|
||||
const isCron = !settings?.cadence.startsWith('P');
|
||||
if (!isCron) {
|
||||
const cadence = Duration.fromISO(settings.cadence);
|
||||
if (cadence < workCheckFrequency) {
|
||||
workCheckFrequency = cadence;
|
||||
}
|
||||
}
|
||||
|
||||
let attemptNum = 1;
|
||||
(async () => {
|
||||
for (;;) {
|
||||
@@ -69,7 +78,7 @@ export class TaskWorker {
|
||||
break;
|
||||
}
|
||||
|
||||
await sleep(this.workCheckFrequency, options?.signal);
|
||||
await sleep(workCheckFrequency, options?.signal);
|
||||
}
|
||||
|
||||
this.logger.info(`Task worker finished: ${this.taskId}`);
|
||||
|
||||
Reference in New Issue
Block a user