Skip to content

Commit 5744524

Browse files
committed
new async iterable version of batch trigger
1 parent dea5ce4 commit 5744524

File tree

3 files changed

+1447
-436
lines changed

3 files changed

+1447
-436
lines changed

packages/core/src/v3/types/tasks.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,16 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
581581

582582
/**
583583
* Batch trigger multiple task runs with the given payloads, and continue without waiting for the results. If you want to wait for the results, use `batchTriggerAndWait`. Returns the id of the triggered batch.
584-
* @param items
584+
* @param items - Array, AsyncIterable, or ReadableStream of batch items
585585
* @returns InvokeBatchHandle
586586
* - `batchId` - The id of the triggered batch.
587587
* - `runs` - The ids of the triggered task runs.
588588
*/
589589
batchTrigger: (
590-
items: Array<BatchItem<TInput>>,
590+
items:
591+
| Array<BatchItem<TInput>>
592+
| AsyncIterable<BatchItem<TInput>>
593+
| ReadableStream<BatchItem<TInput>>,
591594
options?: BatchTriggerOptions,
592595
requestOptions?: TriggerApiRequestOptions
593596
) => Promise<BatchRunHandle<TIdentifier, TInput, TOutput>>;
@@ -616,7 +619,7 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
616619

617620
/**
618621
* Batch trigger multiple task runs with the given payloads, and wait for the results. Returns the results of the task runs.
619-
* @param items
622+
* @param items - Array, AsyncIterable, or ReadableStream of batch items
620623
* @returns BatchResult
621624
* @example
622625
* ```
@@ -635,7 +638,10 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
635638
* ```
636639
*/
637640
batchTriggerAndWait: (
638-
items: Array<BatchTriggerAndWaitItem<TInput>>,
641+
items:
642+
| Array<BatchTriggerAndWaitItem<TInput>>
643+
| AsyncIterable<BatchTriggerAndWaitItem<TInput>>
644+
| ReadableStream<BatchTriggerAndWaitItem<TInput>>,
639645
options?: BatchTriggerAndWaitOptions
640646
) => Promise<BatchResult<TIdentifier, TOutput>>;
641647
}

0 commit comments

Comments
 (0)