Skip to content

Commit

Permalink
tweak the catalog batch parent task
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktrn committed Jan 10, 2025
1 parent 7127ba4 commit a655fee
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions references/v3-catalog/src/trigger/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { setTimeout } from "node:timers/promises";

export const batchParentTask = task({
id: "batch-parent-task",
run: async () => {
const items = Array.from({ length: 10 }, (_, i) => ({
run: async (payload: { size?: number; wait?: boolean }) => {
const items = Array.from({ length: payload.size ?? 10 }, (_, i) => ({
payload: {
id: `item${i}`,
name: `Item Name ${i}`,
Expand All @@ -44,7 +44,9 @@ export const batchParentTask = task({
},
}));

return await batchChildTask.batchTrigger(items);
return payload.wait
? await batchChildTask.batchTriggerAndWait(items.map((i) => ({ payload: i.payload })))
: await batchChildTask.batchTrigger(items);
},
});

Expand Down

0 comments on commit a655fee

Please sign in to comment.