@@ -114,12 +114,17 @@ export const idempotency = task({
114114export const idempotencyBatch = task ( {
115115 id : "idempotency-batch" ,
116116 maxDuration : 60 ,
117- run : async ( payload : any ) => {
117+ run : async ( { additionalItems } : { additionalItems ?: 2 } ) => {
118118 const successfulKey = await idempotencyKeys . create ( "a" , { scope : "global" } ) ;
119119 const failureKey = await idempotencyKeys . create ( "b" , { scope : "global" } ) ;
120120 const anotherKey = await idempotencyKeys . create ( "c" , { scope : "global" } ) ;
121121 const batchKey = await idempotencyKeys . create ( "batch" , { scope : "global" } ) ;
122122
123+ const moreItems = Array . from ( { length : additionalItems ?? 0 } , ( _ , i ) => ( {
124+ payload : { message : `Hello, world ${ i } !` } ,
125+ options : { idempotencyKey : `key-${ i } ` , idempotencyKeyTTL : "120s" } ,
126+ } ) ) ;
127+
123128 const batch1 = await childTask . batchTriggerAndWait (
124129 [
125130 {
@@ -133,6 +138,7 @@ export const idempotencyBatch = task({
133138 {
134139 payload : { message : "Hello, world 3" , duration : 500 , failureChance : 0 } ,
135140 } ,
141+ ...moreItems ,
136142 ] ,
137143 {
138144 idempotencyKey : batchKey ,
@@ -157,6 +163,7 @@ export const idempotencyBatch = task({
157163 {
158164 payload : { message : "Hello, world 3" , duration : 500 , failureChance : 0 } ,
159165 } ,
166+ ...moreItems ,
160167 ] ,
161168 {
162169 idempotencyKey : batchKey ,
0 commit comments