ai-functions
Version:
Core AI primitives for building intelligent applications
44 lines • 1.29 kB
TypeScript
/**
* In-Memory Batch Adapter for Testing
*
* Simulates batch processing locally for testing purposes.
* Executes requests immediately (or with configurable delay).
*
* @packageDocumentation
*/
import { type BatchAdapter, type BatchItem, type BatchQueueOptions, type BatchResult } from './provider.js';
interface MemoryBatch {
id: string;
items: BatchItem[];
options: BatchQueueOptions;
status: 'pending' | 'in_progress' | 'completed' | 'failed';
results: BatchResult[];
createdAt: Date;
completedAt?: Date;
}
/**
* Options for the memory adapter
*/
export interface MemoryAdapterOptions {
/** Simulate processing delay in ms */
delay?: number;
/** Mock handler for custom processing */
handler?: (item: BatchItem) => Promise<unknown>;
/** Simulate failure rate (0-1) */
failureRate?: number;
}
/**
* Configure the memory adapter
*/
export declare function configureMemoryAdapter(options: MemoryAdapterOptions): void;
/**
* Clear all stored batches (for testing)
*/
export declare function clearBatches(): void;
/**
* Get all stored batches (for testing)
*/
export declare function getBatches(): Map<string, MemoryBatch>;
declare const memoryAdapter: BatchAdapter;
export { memoryAdapter };
//# sourceMappingURL=memory.d.ts.map