-
-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prioritize finishing waited runs (#1375)
* If a tree node is missing, estimate the size as zero * Task to test prioritizing finishing existing runs after triggerAndWaits * When requeuing a run with a checkpoint, put it in the queue with the parent run time so it’s correctly prioritized * The same change but if there’s no checkpoint
- Loading branch information
1 parent
ceabfba
commit 0bf500f
Showing
3 changed files
with
47 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
references/hello-world/src/trigger/prioritize-continuing.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { logger, task, wait } from "@trigger.dev/sdk/v3"; | ||
|
||
export const prioritizeContinuing = task({ | ||
id: "prioritize-continuing", | ||
run: async ({ count }: { count: number }) => { | ||
await prioritizeContinuingChild.batchTrigger( | ||
Array.from({ length: count }, (_, i) => ({ payload: {} as any })) | ||
); | ||
}, | ||
}); | ||
|
||
export const prioritizeContinuingChild = task({ | ||
id: "prioritize-continuing-child", | ||
queue: { | ||
concurrencyLimit: 1, | ||
}, | ||
run: async () => { | ||
await fixedLengthTask.triggerAndWait({ waitSeconds: 1 }); | ||
}, | ||
}); | ||
|
||
export const fixedLengthTask = task({ | ||
id: "fixedLengthTask", | ||
run: async ({ waitSeconds }: { waitSeconds: number }) => { | ||
await new Promise((resolve) => setTimeout(resolve, waitSeconds * 1000)); | ||
}, | ||
}); |