Skip to content

Commit b96ddfd

Browse files
committed
Added a simple batchTriggerAndWait example
1 parent 0055c05 commit b96ddfd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

references/hello-world/src/trigger/example.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,21 @@ export const maxDurationParentTask = task({
6868
return result;
6969
},
7070
});
71+
72+
export const batchTask = task({
73+
id: "batch",
74+
run: async (payload: { count: number }, { ctx }) => {
75+
logger.info("Starting batch task", { count: payload.count });
76+
77+
const items = Array.from({ length: payload.count }, (_, i) => ({
78+
payload: { message: `Batch item ${i + 1}` },
79+
}));
80+
81+
const results = await childTask.batchTriggerAndWait(items);
82+
83+
return {
84+
batchCount: payload.count,
85+
results,
86+
};
87+
},
88+
});

0 commit comments

Comments
 (0)