UNPKG

uid-pool

Version:

High-performance UUID and unique ID pooling for Node.js. Pre-generate IDs in background worker threads for O(1) synchronous acquisition. Drop-in replacement for uuid.v4() and nanoid() with 10-100x better performance under load.

32 lines 1.53 kB
import { BaseIdPool } from "../core/pool.js"; import type { IdPoolOptions } from "../core/types.js"; export declare const WORKER_TIMEOUT = 5000; /** * Node.js implementation of IdPool using worker threads for non-blocking generation. */ export declare class IdPool extends BaseIdPool { private worker; private pendingRefill; private constructor(); /** * Create a new IdPool instance that is ready for use. */ static create(options: IdPoolOptions): Promise<IdPool>; protected startInternal(): void; protected stopInternal(): Promise<void>; protected triggerRefill(): Promise<void>; private doRefill; private generateInWorker; /** * Sets up timeout and message handler for worker communication. */ private setupWorkerMessageHandler; /** * Sends generation request to worker with proper error handling. */ private sendGenerationRequest; private generateInMainThread; } export type { IdPoolOptions, PoolStats } from "../core/types.js"; export { IdPoolError, InvalidConfigurationError, InvalidGeneratorError, InvalidPoolSizeError, InvalidMinSizeError, InvalidRefillBatchSizeError, InvalidCapacityError, PoolEmptyError, PoolNotReadyError, PoolStoppedError, PoolTimeoutError, GeneratorFailureError, InvalidGeneratorOutputError, WorkerNotInitializedError, WorkerTimeoutError, WorkerCrashError, WorkerGenerationError, SerializationError, ResourceExhaustionError, InvalidRuntimeError, } from "../core/errors.js"; //# sourceMappingURL=index.d.ts.map