UNPKG

firestore-queue

Version:

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

72 lines 2.46 kB
import { FireQueue } from '../core/FireQueue'; import { FirestoreWriter } from '../writers/FirestoreWriter'; import { QueueConfig } from '../types'; /** * Simple Fire Queue Setup * Only requires: dbId, service account, and topic (queue name) */ export interface SimpleQueueConfig { /** * Your Google Cloud Project ID (optional - auto-extracted from service account file) */ projectId?: string; /** * Firestore database ID (optional, defaults to "firequeue" - automatically created if not exists) */ dbId?: string; /** * Path to Firebase service account JSON file (optional - auto-detected in config/firebase-service-account.json) */ serviceAccountPath?: string; /** * Pre-configured Firestore instance (alternative to serviceAccountPath) */ firestoreInstance?: any; /** * Queue name (topic) - this becomes your Firestore collection name */ topic: string; /** * Trigger mapping for automatic processing (optional) * Maps queue topics to Pub/Sub trigger topics * Example: { 'content-topic': 'content-processing-trigger' } */ triggerMapping?: Record<string, string>; } /** * Create a Fire Queue with minimal configuration * Perfect for quick setup and testing */ export declare function createSimpleQueue(config: SimpleQueueConfig): { queue: FireQueue; writer: FirestoreWriter; config: QueueConfig; }; /** * One-liner setup for the simplest use case */ export declare function quickStart(projectId: string, serviceAccountPath: string, topic: string, dbId?: string): { queue: FireQueue; writer: FirestoreWriter; }; /** * Setup with automatic initialization */ export declare function createReadyQueue(config: SimpleQueueConfig): 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>; }>; /** * Create a queue with automatic consumer setup */ export declare function createQueueWithConsumer(config: SimpleQueueConfig, consumerId: string, messageHandler: (messages: any[]) => Promise<void>): Promise<{ queue: FireQueue; writer: FirestoreWriter; enqueue: (type: string, payload: any) => Promise<string>; shutdown: () => Promise<void>; }>; //# sourceMappingURL=simple-setup.d.ts.map