-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(sdk,core,webapp,run-engine): task concurrency option and shareable named limits #4827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
6e3bd4f
feat(sdk,core,webapp,run-engine): declare queue gates on tasks and tr…
matt-aitken 87ff489
fix(core,sdk,webapp): bound gate tuples at two and normalize queues once
matt-aitken d161de5
fix(core,database): mirror gates into the run-ops schema and reject e…
matt-aitken 4d9ae99
fix(react-hooks): accept queue gate tuples in useTaskTrigger
matt-aitken 3f70ebf
fix(react-hooks): one-element queue tuple clears task-level gates
matt-aitken 141b9fa
refactor(core,sdk): rename combined concurrency fields in gate types
matt-aitken aac307f
refactor(sdk,core,webapp): rename totalConcurrencyLimit to combinedCo…
matt-aitken 3838001
fix(core): duplicate queue warning covers the combined limit
matt-aitken e102a86
fix(sdk): string queue names in tasks are references, not definitions
matt-aitken 8dd95d4
fix(webapp): order reference-created named queues by queue name
matt-aitken c1dff1b
fix(webapp,run-engine): stored gates obey the gate contract
matt-aitken 944cb08
refactor(run-engine,webapp): one shared gate parser with tests
matt-aitken 034e326
feat(sdk,core,cli): the concurrency option and named concurrency limits
matt-aitken 852f990
fix(core,sdk,react-hooks): finish the concurrency-option surface swap
matt-aitken 3a8e251
fix(webapp): a replayed run keeps its original gate set, empty included
matt-aitken 305b2a3
fix(core): the worker manifest carries the declared concurrency limits
matt-aitken 42ab3c1
fix(sdk): reject more than two trigger-time named limits instead of d…
matt-aitken 3309c5d
fix(sdk): concurrency reaches every trigger path
matt-aitken 806ef18
fix(sdk): concurrencyLimit names are 1-122 characters without slashes
matt-aitken d511ac6
fix(sdk): inline named limits share the factory's name validation
matt-aitken 7ca6506
fix(sdk): restrict concurrency limit names to a queue-safe charset
matt-aitken 833f0a2
fix(core,run-engine): gates carry a task's inline limit plus two name…
matt-aitken ff350ef
fix(webapp,run-engine): replays survive gate growth across deploys
matt-aitken 951fadd
fix(core): the combined limit caps keyed and keyless runs together
matt-aitken c7d4ef6
feat(core): concurrency limit read and override schemas
matt-aitken 13c5bc5
feat(sdk,core): the concurrencyLimits namespace
matt-aitken 9807331
fix(react-hooks): reject more than two named limits instead of trunca…
matt-aitken f4cebc9
test(webapp): metadata-cache test entries carry the gates field the e…
matt-aitken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| "@trigger.dev/core": patch | ||
| --- | ||
|
|
||
| Queue retrieve and list API responses now report combined concurrency usage. When a queue has a `combinedConcurrencyLimit`, `concurrency.combined` includes the effective cap, the declared base, any active override, and how many runs are in flight across all concurrency keys. |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,23 @@ | ||
| --- | ||
| "@trigger.dev/sdk": patch | ||
| "@trigger.dev/core": patch | ||
| "@trigger.dev/react-hooks": patch | ||
| --- | ||
|
|
||
| Control a task's concurrency with the new `concurrency` option, and share limits across tasks with named concurrency limits. An inline shape caps the task itself; `concurrencyLimit()` declares a limit any task can hold (up to two named limits per task), and a trigger call can switch a run's named limits with its own `concurrency` option. | ||
|
|
||
| ```ts | ||
| import { concurrencyLimit, task } from "@trigger.dev/sdk"; | ||
|
|
||
| export const openaiLimit = concurrencyLimit({ name: "openai", total: 25 }); | ||
|
|
||
| export const generateSummary = task({ | ||
| id: "generate-summary", | ||
| concurrency: [{ perKey: 1, total: 5 }, openaiLimit], | ||
| run: async (payload) => {}, | ||
| }); | ||
| ``` | ||
|
|
||
| `perKey` caps each `concurrencyKey` pool and `total` caps across everything, keys or not. The queue-level `concurrencyLimit` option keeps working unchanged and is deprecated in favor of `concurrency`. Enforcement happens server-side; servers without support accept the option but do not enforce it yet. | ||
|
|
||
| Manage limits at runtime with the new `concurrencyLimits` namespace: `list()` and `retrieve(name)` report each limit's bounds plus its live `running` and `queued` counts, `override(name, { perKey, total })` changes only the given bounds (overriding `total` to `0` pauses the limit), and `reset(name)` restores the declared values. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.