UNPKG

@dollhousemcp/mcp-server

Version:

DollhouseMCP - A Model Context Protocol (MCP) server that enables dynamic AI persona management from markdown files, allowing Claude and other compatible AI assistants to activate and switch between different behavioral personas.

70 lines 2.21 kB
/** * FileLockManager - Prevents race conditions in concurrent file operations * * Features: * - Resource-based locking with automatic cleanup * - Configurable timeouts to prevent deadlocks * - Atomic file operations with write-rename pattern * - Lock queueing for concurrent requests * - Comprehensive error handling and logging * - Performance metrics tracking */ export declare class FileLockManager { private static locks; private static metrics; private static readonly DEFAULT_TIMEOUT_MS; private static readonly TEMP_DIR; /** * Execute an operation with exclusive lock on a resource * @param resource - Unique identifier for the resource (e.g., 'persona:name') * @param operation - Async function to execute while holding the lock * @param options - Lock options including timeout * @returns Result of the operation */ static withLock<T>(resource: string, operation: () => Promise<T>, options?: { timeout?: number; }): Promise<T>; /** * Execute operation with timeout protection */ private static executeWithTimeout; /** * Perform atomic file write operation * Writes to temporary file then renames to ensure atomicity */ static atomicWriteFile(filePath: string, content: string, options?: { encoding?: BufferEncoding; }): Promise<void>; /** * Perform atomic file read with lock */ static atomicReadFile(filePath: string, options?: { encoding?: BufferEncoding; }): Promise<string>; /** * Generate temporary file path for atomic operations */ private static getTempFilePath; /** * Get lock metrics for monitoring */ static getMetrics(): { totalRequests: number; activeLocksCount: number; timeouts: number; concurrentWaits: number; avgWaitTimeByResource: { [k: string]: number; }; activeLocks: string[]; }; /** * Clear all locks (use with caution - mainly for testing) */ static clearAllLocks(): void; /** * Reset metrics */ static resetMetrics(): void; } //# sourceMappingURL=fileLockManager.d.ts.map