Skip to content

Commit 414e5a2

Browse files
matt-aitkenTrigger.dev RepoOps
authored andcommitted
chore(sdk): deprecate queues.overrideConcurrencyLimit and resetConcurrencyLimit
## Summary Marks `queues.overrideConcurrencyLimit` and `queues.resetConcurrencyLimit` as deprecated in the SDK. These functions belong to the legacy model where a queue carried its own concurrency limit. On the current model a queue is only the ordered line runs wait in, concurrency is declared on the task with the `concurrency` option, and limits are managed through `concurrencyLimits.override` and `concurrencyLimits.reset`. The server already rejects these calls for queues on the current model. The `@deprecated` JSDoc includes a migration example: ```ts export const myTask = task({ id: "my-task", concurrency: { total: 5 }, run: async (payload) => { // ... }, }); await concurrencyLimits.override("task/my-task", { total: 10 }); ``` Also adds a deprecation callout to the queues docs pointing at the concurrency docs, plus a changeset. `queues.pause` and `queues.resume` are intentionally not deprecated: pausing a queue remains valid flow control on the current model. Mono-RevId: e75902f159eda3487596ba4d038ed5eedc45bee8
1 parent fa94feb commit 414e5a2

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
---
4+
5+
Deprecate `queues.overrideConcurrencyLimit` and `queues.resetConcurrencyLimit`. These operate on the legacy model where a queue carried its own concurrency limit; declare concurrency with the task `concurrency` option and manage it with `concurrencyLimits.override` and `concurrencyLimits.reset` instead.

‎docs/queues.mdx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ await queues.resume({ type: "custom", name: "my-custom-queue" });
210210

211211
### Overriding concurrency limits
212212

213+
<Warning>
214+
`queues.overrideConcurrencyLimit` and `queues.resetConcurrencyLimit` are deprecated and only work
215+
for queues on the legacy model, where the queue carried its own concurrency limit. On the current
216+
model, declare concurrency with the task `concurrency` option and manage it through
217+
[`concurrencyLimits`](/concurrency), e.g. `concurrencyLimits.override("task/my-task", { total: 10 })`
218+
and `concurrencyLimits.reset("task/my-task")`. A legacy limit on a queue used with
219+
`concurrencyKey` maps to `perKey` rather than `total`, and a limit on a custom queue shared by
220+
several tasks maps to a named limit declared with `concurrencyLimit()`, again using `perKey`
221+
when the queue receives keyed runs.
222+
</Warning>
223+
213224
You can temporarily override a queue's concurrency limit. This is useful for scaling up or down based on demand:
214225

215226
```ts

‎packages/trigger-sdk/src/v3/queues.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,28 @@ export function pause(
137137
/**
138138
* Overrides the concurrency limit of a queue.
139139
*
140+
* @deprecated Queue-level concurrency is the legacy model: a modern queue is only the
141+
* ordered line runs wait in, and concurrency is declared on the task and managed
142+
* through `concurrencyLimits`. The server rejects this call for queues on the new
143+
* model. Migrate by declaring the limit and overriding it by name:
144+
*
145+
* ```ts
146+
* export const myTask = task({
147+
* id: "my-task",
148+
* concurrency: { total: 5 },
149+
* run: async (payload) => {
150+
* // ...
151+
* },
152+
* });
153+
*
154+
* await concurrencyLimits.override("task/my-task", { total: 10 });
155+
* ```
156+
*
157+
* For workloads that pass a `concurrencyKey` at trigger time, declare `concurrency: { perKey: n }`
158+
* instead (`total` caps all keys together). For a limit shared by several tasks, declare a named
159+
* limit with `concurrencyLimit({ name, ... })`, making the same choice between `total` and
160+
* `perKey`, pass it to each task's `concurrency` option, and override it by that name.
161+
*
140162
* @param queue - The ID of the queue to override the concurrency limit, or the type and name
141163
* @param concurrencyLimit - The concurrency limit to override
142164
* @returns The updated queue state
@@ -175,6 +197,15 @@ export function overrideConcurrencyLimit(
175197
/**
176198
* Resets the concurrency limit of a queue to the base value.
177199
*
200+
* @deprecated Queue-level concurrency is the legacy model: a modern queue is only the
201+
* ordered line runs wait in, and concurrency is declared on the task and managed
202+
* through `concurrencyLimits`. The server rejects this call for queues on the new
203+
* model. Migrate by resetting the limit by name:
204+
*
205+
* ```ts
206+
* await concurrencyLimits.reset("task/my-task");
207+
* ```
208+
*
178209
* @param queue - The ID of the queue to reset the concurrency limit, or the type and name
179210
* @returns The updated queue state
180211
*/

0 commit comments

Comments
 (0)