-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(sdk,core,webapp,run-engine): declare queue gates on tasks and triggers #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
10 commits
Select commit
Hold shift + click to select a range
c4abf01
feat(sdk,core,webapp,run-engine): declare queue gates on tasks and tr…
matt-aitken 34e7e3f
fix(core,sdk,webapp): bound gate tuples at two and normalize queues once
matt-aitken 8660e7a
fix(core,database): mirror gates into the run-ops schema and reject e…
matt-aitken 3bbd8f0
fix(react-hooks): accept queue gate tuples in useTaskTrigger
matt-aitken 91d2150
fix(react-hooks): one-element queue tuple clears task-level gates
matt-aitken e95cba8
refactor(core,sdk): rename combined concurrency fields in gate types
matt-aitken 6acdac8
refactor(sdk,core,webapp): rename totalConcurrencyLimit to combinedCo…
matt-aitken e8c1e70
fix(core): duplicate queue warning covers the combined limit
matt-aitken ba52fab
fix(sdk): string queue names in tasks are references, not definitions
matt-aitken 9e6929d
fix(webapp): order reference-created named queues by queue name
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
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,18 @@ | ||
| --- | ||
| "@trigger.dev/sdk": patch | ||
| "@trigger.dev/core": patch | ||
| --- | ||
|
|
||
| Cap a queue's combined concurrency across all of its `concurrencyKey` values with the new `combinedConcurrencyLimit` queue option. On a keyed queue, `concurrencyLimit` applies to each key value independently, so ten active keys with a limit of 5 can run 50 at once. `combinedConcurrencyLimit` bounds the whole queue while each key still gets at most `concurrencyLimit`. | ||
|
|
||
| ```ts | ||
| import { queue } from "@trigger.dev/sdk"; | ||
|
|
||
| export const perUserQueue = queue({ | ||
| name: "per-user-queue", | ||
| concurrencyLimit: 1, | ||
| combinedConcurrencyLimit: 10, | ||
| }); | ||
| ``` | ||
|
|
||
| Enforcement happens server-side and only applies to runs triggered with a `concurrencyKey`. Servers that have not enabled combined concurrency limits accept the option but do not enforce it yet. |
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 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,22 @@ | ||
| --- | ||
| "@trigger.dev/sdk": patch | ||
| "@trigger.dev/core": patch | ||
| --- | ||
|
|
||
| Hold a run's concurrency slot in more than one queue with queue gates. Pass an array as `queue`: the first entry is the queue the run waits in, and up to two more name gates, other queues the run must also have capacity in and occupies while it executes. A gate without a `concurrencyKey` uses the run's own key, so a shared `tenant` queue caps a tenant across every task; a literal key pins the gate to one slot pool, capping, say, all traffic to one external provider. | ||
|
|
||
| ```ts | ||
| import { queue, task } from "@trigger.dev/sdk"; | ||
|
|
||
| export const tenant = queue({ name: "tenant", concurrencyLimit: 10 }); | ||
|
|
||
| export const processWebhook = task({ | ||
| id: "process-webhook", | ||
| queue: [{ name: "webhooks", concurrencyLimit: 2 }, "tenant"], | ||
| run: async (payload) => {}, | ||
| }); | ||
|
|
||
| await processWebhook.trigger(payload, { concurrencyKey: tenantId }); | ||
| ``` | ||
|
|
||
| The same array form works on `queue` when triggering, replacing the task's gates for that run. Enforcement happens server-side; servers without queue gates enabled accept the option but run without it. |
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
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.
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.