|
1 | 1 | # internal-platform |
2 | 2 |
|
| 3 | +## 3.3.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- Improved Batch Triggering: ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) |
| 8 | + |
| 9 | + - The new Batch Trigger endpoint is now asynchronous and supports up to 500 runs per request. |
| 10 | + - The new endpoint also supports triggering multiple different tasks in a single batch request (support in the SDK coming soon). |
| 11 | + - The existing `batchTrigger` method now supports the new endpoint, and shouldn't require any changes to your code. |
| 12 | + |
| 13 | + - Idempotency keys now expire after 24 hours, and you can customize the expiration time when creating a new key by using the `idempotencyKeyTTL` parameter: |
| 14 | + |
| 15 | + ```ts |
| 16 | + await myTask.batchTrigger([{ payload: { foo: "bar" } }], { |
| 17 | + idempotencyKey: "my-key", |
| 18 | + idempotencyKeyTTL: "60s", |
| 19 | + }); |
| 20 | + // Works for individual items as well: |
| 21 | + await myTask.batchTrigger([ |
| 22 | + { payload: { foo: "bar" }, options: { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" } }, |
| 23 | + ]); |
| 24 | + // And `trigger`: |
| 25 | + await myTask.trigger({ foo: "bar" }, { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" }); |
| 26 | + ``` |
| 27 | + |
| 28 | + ### Breaking Changes |
| 29 | + |
| 30 | + - We've removed the `idempotencyKey` option from `triggerAndWait` and `batchTriggerAndWait`, because it can lead to permanently frozen runs in deployed tasks. We're working on upgrading our entire system to support idempotency keys on these methods, and we'll re-add the option once that's complete. |
| 31 | + |
| 32 | +### Patch Changes |
| 33 | + |
| 34 | +- Added new batch.trigger and batch.triggerByTask methods that allows triggering multiple different tasks in a single batch: ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) |
| 35 | + |
| 36 | + ```ts |
| 37 | + import { batch } from "@trigger.dev/sdk/v3"; |
| 38 | + import type { myTask1, myTask2 } from "./trigger/tasks"; |
| 39 | + |
| 40 | + // Somewhere in your backend code |
| 41 | + const response = await batch.trigger<typeof myTask1 | typeof myTask2>([ |
| 42 | + { id: "task1", payload: { foo: "bar" } }, |
| 43 | + { id: "task2", payload: { baz: "qux" } }, |
| 44 | + ]); |
| 45 | + |
| 46 | + for (const run of response.runs) { |
| 47 | + if (run.ok) { |
| 48 | + console.log(run.output); |
| 49 | + } else { |
| 50 | + console.error(run.error); |
| 51 | + } |
| 52 | + } |
| 53 | + ``` |
| 54 | + |
| 55 | + Or if you are inside of a task, you can use `triggerByTask`: |
| 56 | + |
| 57 | + ```ts |
| 58 | + import { batch, task, runs } from "@trigger.dev/sdk/v3"; |
| 59 | + |
| 60 | + export const myParentTask = task({ |
| 61 | + id: "myParentTask", |
| 62 | + run: async () => { |
| 63 | + const response = await batch.triggerByTask([ |
| 64 | + { task: myTask1, payload: { foo: "bar" } }, |
| 65 | + { task: myTask2, payload: { baz: "qux" } }, |
| 66 | + ]); |
| 67 | + |
| 68 | + const run1 = await runs.retrieve(response.runs[0]); |
| 69 | + console.log(run1.output); // typed as { foo: string } |
| 70 | + |
| 71 | + const run2 = await runs.retrieve(response.runs[1]); |
| 72 | + console.log(run2.output); // typed as { baz: string } |
| 73 | + |
| 74 | + const response2 = await batch.triggerByTaskAndWait([ |
| 75 | + { task: myTask1, payload: { foo: "bar" } }, |
| 76 | + { task: myTask2, payload: { baz: "qux" } }, |
| 77 | + ]); |
| 78 | + |
| 79 | + if (response2.runs[0].ok) { |
| 80 | + console.log(response2.runs[0].output); // typed as { foo: string } |
| 81 | + } |
| 82 | + |
| 83 | + if (response2.runs[1].ok) { |
| 84 | + console.log(response2.runs[1].output); // typed as { baz: string } |
| 85 | + } |
| 86 | + }, |
| 87 | + }); |
| 88 | + |
| 89 | + export const myTask1 = task({ |
| 90 | + id: "myTask1", |
| 91 | + run: async () => { |
| 92 | + return { |
| 93 | + foo: "bar", |
| 94 | + }; |
| 95 | + }, |
| 96 | + }); |
| 97 | + |
| 98 | + export const myTask2 = task({ |
| 99 | + id: "myTask2", |
| 100 | + run: async () => { |
| 101 | + return { |
| 102 | + baz: "qux", |
| 103 | + }; |
| 104 | + }, |
| 105 | + }); |
| 106 | + ``` |
| 107 | + |
| 108 | +- Added ability to subscribe to a batch of runs using runs.subscribeToBatch ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) |
| 109 | + |
3 | 110 | ## 3.2.2 |
4 | 111 |
|
5 | 112 | ## 3.2.1 |
|
0 commit comments