crewai-ts
Version:
TypeScript port of crewAI for agent-based workflows
130 lines • 3.17 kB
TypeScript
/**
* MongoDBStorageAdapter
*
* A MongoDB-based implementation of the StorageAdapter interface
* Optimized for distributed systems with high scalability requirements
*/
import { BaseStorageAdapter, StorageAdapterOptions } from './StorageAdapter.js';
/**
* MongoDBStorageAdapter Options
*/
export interface MongoDBStorageOptions extends StorageAdapterOptions {
/**
* MongoDB connection URI
*/
uri: string;
/**
* Database name
*/
database: string;
/**
* Collection name prefix
* The actual collection will be `${collectionPrefix}_${namespace}`
*/
collectionPrefix?: string;
/**
* Connection options
*/
connectionOptions?: any;
/**
* Enable client-side caching
*/
enableCache?: boolean;
/**
* Maximum number of items to cache
*/
maxCacheSize?: number;
/**
* Enable bulk operations for better performance
*/
enableBulkOperations?: boolean;
/**
* Bulk operation batch size
*/
bulkBatchSize?: number;
/**
* Create indexes for better query performance
*/
createIndexes?: boolean;
}
/**
* MongoDBStorageAdapter implements the StorageAdapter interface
* using MongoDB for highly scalable distributed storage
*
* Note: This implementation requires the 'mongodb' package
* npm install mongodb
*/
export declare class MongoDBStorageAdapter extends BaseStorageAdapter {
private client;
private db;
private collection;
private connected;
private connecting;
private connectionPromise;
private enableCache;
private maxCacheSize;
private cache;
private bulkOps;
private bulkBatchSize;
private pendingOps;
private bulkTimer;
private collectionName;
constructor(options: MongoDBStorageOptions);
/**
* Initialize MongoDB client with optimal configuration
*/
private initClient;
/**
* Create indexes for better performance
*/
private createIndexes;
/**
* Ensure MongoDB client is connected
*/
private ensureConnected;
/**
* Add an item to the cache with LRU eviction
*/
private addToCache;
/**
* Schedule bulk operations execution
*/
private scheduleBulkOps;
/**
* Execute pending bulk operations
*/
private executeBulkOps;
/**
* Save a value to MongoDB with high optimization
*/
save(key: string, value: any): Promise<void>;
/**
* Load a value from MongoDB with caching
*/
load(key: string): Promise<any | null>;
/**
* Delete a value from MongoDB with cache invalidation
*/
delete(key: string): Promise<boolean>;
/**
* Clear all values in the namespace
*/
clear(): Promise<void>;
/**
* Get all keys in the namespace
*/
keys(): Promise<string[]>;
/**
* Close the MongoDB client connection
*/
close(): Promise<void>;
/**
* Get MongoDB stats
*/
getStats(): Promise<any>;
/**
* Perform database maintenance operations
*/
optimize(): Promise<void>;
}
//# sourceMappingURL=MongoDBStorageAdapter.d.ts.map