Skip to content

Commit bb95118

Browse files
committed
Removed batchOptions from the trigger options and the docs
1 parent a7c10ce commit bb95118

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.changeset/smart-needles-move.md

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+
Remove unimplemented batchOptions

docs/v3/triggering.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@ This is where it gets interesting. You can trigger a task and then wait for the
168168
<Accordion title="Don't use this in parallel, e.g. with `Promise.all()`">
169169
Instead, use `batchTriggerAndWait()` if you can, or a for loop if you can't.
170170

171+
To control concurrency using batch triggers, you can set `queue.concurrencyLimit` on the child task.
172+
171173
<CodeGroup>
172174
```ts /trigger/batch.ts
173175
export const batchTask = task({
174176
id: "batch-task",
175177
run: async (payload: string) => {
176178
const results = await childTask.batchTriggerAndWait({
177179
items: [{ payload: "item1" }, { payload: "item2" }],
178-
// optional: how many to run in parallel
179-
batchOptions: { maxConcurrency: 1 },
180180
});
181181
console.log("Results", results);
182182

@@ -189,6 +189,8 @@ export const batchTask = task({
189189
export const loopTask = task({
190190
id: "loop-task",
191191
run: async (payload: string) => {
192+
//this will be slower than the batch version
193+
//as we have to resume the parent after each iteration
192194
for (let i = 0; i < 2; i++) {
193195
const result = await childTask.triggerAndWait({ payload: `item${i}` });
194196
console.log("Result", result);
@@ -221,15 +223,15 @@ You can batch trigger a task and wait for all the results. This is useful for th
221223
<Accordion title="Don't use this in parallel, e.g. with `Promise.all()`">
222224
Instead, pass in all items at once and set an appropriate `maxConcurrency`. Alternatively, use sequentially with a for loop.
223225

226+
To control concurrency, you can set `queue.concurrencyLimit` on the child task.
227+
224228
<CodeGroup>
225229
```ts /trigger/batch.ts
226230
export const batchTask = task({
227231
id: "batch-task",
228232
run: async (payload: string) => {
229233
const results = await childTask.batchTriggerAndWait({
230234
items: [{ payload: "item1" }, { payload: "item2" }],
231-
// optional: how many tasks to run in parallel
232-
batchOptions: { maxConcurrency: 1 },
233235
});
234236
console.log("Results", results);
235237

@@ -242,11 +244,11 @@ export const batchTask = task({
242244
export const loopTask = task({
243245
id: "loop-task",
244246
run: async (payload: string) => {
247+
//this will be slower than a single batchTriggerAndWait()
248+
//as we have to resume the parent after each iteration
245249
for (let i = 0; i < 2; i++) {
246250
const result = await childTask.batchTriggerAndWait({
247251
items: [{ payload: `itemA${i}` }, { payload: `itemB${i}` }],
248-
// optional: how many tasks to run in parallel
249-
batchOptions: { maxConcurrency: 1 },
250252
});
251253
console.log("Result", result);
252254

packages/trigger-sdk/src/v3/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ export interface Task<TInput, TOutput = any> {
179179
trigger: (params: { payload: TInput; options?: TaskRunOptions }) => Promise<InvokeHandle>;
180180
batchTrigger: (params: {
181181
items: { payload: TInput; options?: TaskRunOptions }[];
182-
batchOptions?: BatchRunOptions;
182+
// batchOptions?: BatchRunOptions;
183183
}) => Promise<InvokeBatchHandle>;
184184
triggerAndWait: (params: { payload: TInput; options?: TaskRunOptions }) => Promise<TOutput>;
185185
batchTriggerAndWait: (params: {
186186
items: { payload: TInput; options?: TaskRunOptions }[];
187-
batchOptions?: BatchRunOptions;
187+
// batchOptions?: BatchRunOptions;
188188
}) => Promise<BatchResult<TOutput>>;
189189
}
190190

0 commit comments

Comments
 (0)