@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
29 lines (28 loc) • 964 B
TypeScript
import { MaybePromise } from '../../types';
export type BatchCallbackLookup<V, R> = (value: V) => MaybePromise<R>;
export type BatchCallback<V, R> = (values: V[]) => MaybePromise<Map<V, R> | BatchCallbackLookup<V, R>>;
export type BatchOptions = {
maxBatchSize?: number;
maxWaitMilliseconds?: number;
};
export declare class BatchProcessor<V, R> {
private readonly callback;
private readonly options;
private readonly queue;
private timeout;
private waitingSince;
constructor(callback: BatchCallback<V, R>, options?: BatchOptions);
batch(value: V): Promise<R>;
process(): void;
private requestProcessQueue;
private waitToProcessQueue;
private shouldProcessNow;
private maxBatchSizeReached;
private maxWaitReached;
private getBatchToProcess;
private processQueue;
private resolveBatchUsingMap;
private resolveBatchUsingLookup;
private rejectBatch;
private isBatchCallbackLookup;
}