Skip to content

Commit a655fee

Browse files
committed
tweak the catalog batch parent task
1 parent 7127ba4 commit a655fee

File tree

1 file changed

+5
-3
lines changed
  • references/v3-catalog/src/trigger

1 file changed

+5
-3
lines changed

references/v3-catalog/src/trigger/batch.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import { setTimeout } from "node:timers/promises";
1616

1717
export const batchParentTask = task({
1818
id: "batch-parent-task",
19-
run: async () => {
20-
const items = Array.from({ length: 10 }, (_, i) => ({
19+
run: async (payload: { size?: number; wait?: boolean }) => {
20+
const items = Array.from({ length: payload.size ?? 10 }, (_, i) => ({
2121
payload: {
2222
id: `item${i}`,
2323
name: `Item Name ${i}`,
@@ -44,7 +44,9 @@ export const batchParentTask = task({
4444
},
4545
}));
4646

47-
return await batchChildTask.batchTrigger(items);
47+
return payload.wait
48+
? await batchChildTask.batchTriggerAndWait(items.map((i) => ({ payload: i.payload })))
49+
: await batchChildTask.batchTrigger(items);
4850
},
4951
});
5052

0 commit comments

Comments
 (0)