UNPKG

firestore-queue

Version:

A powerful, scalable queue system built on Google Firestore with time-based indexing, auto-configuration, and connection reuse

79 lines 2.51 kB
import { FireQueue } from '../core/FireQueue'; import { FirestoreWriter } from '../writers/FirestoreWriter'; import * as admin from 'firebase-admin'; /** * FireQueue Manager for reusable configurations and connections * Provides a standard way to initialize and manage multiple queues */ export declare class FireQueueManager { private firestoreInstance?; private baseConfig; private queues; constructor(config: { projectId: string; serviceAccountPath?: string; firestoreInstance?: admin.firestore.Firestore; dbId?: string; }); /** * Configure the manager with connection details * This is the standard initialization method */ static configure(config: { projectId: string; serviceAccountPath?: string; firestoreInstance?: admin.firestore.Firestore; dbId?: string; }): Promise<FireQueueManager>; /** * Create a new queue with the manager's base configuration */ createQueue(topic: string, options?: { dbId?: string; serviceAccountPath?: string; }): Promise<{ queue: FireQueue; writer: FirestoreWriter; enqueue: (type: string, payload: any, options?: any) => Promise<string>; consume: (consumerId: string, handler: any) => Promise<void>; getMetrics: () => Promise<any>; shutdown: () => Promise<void>; }>; /** * Get an existing queue by topic name */ getQueue(topic: string): { queue: FireQueue; writer: FirestoreWriter; enqueue: (type: string, payload: any, options?: any) => Promise<string>; consume: (consumerId: string, handler: any) => Promise<void>; getMetrics: () => Promise<any>; shutdown: () => Promise<void>; } | undefined; /** * List all managed queues */ listQueues(): string[]; /** * Get the shared Firestore instance */ getFirestoreInstance(): admin.firestore.Firestore | undefined; /** * Shutdown all managed queues */ shutdown(): Promise<void>; /** * Get metrics for all queues */ getAllMetrics(): Promise<Record<string, any>>; } /** * Simplified factory function for the most common use case */ export declare function setupFireQueue(config: { projectId: string; serviceAccountPath?: string; firestoreInstance?: admin.firestore.Firestore; dbId?: string; }): Promise<FireQueueManager>; //# sourceMappingURL=queue-manager.d.ts.map