UNPKG

mongo2crate

Version:

Sync MongoDB to CrateDB and Convert JSON schema to SQL DDL

72 lines (71 loc) 3.17 kB
import type { Redis } from 'ioredis'; import { type ChangeStreamOptions, type ScanOptions } from 'mongochangestream'; import * as mongoChangeStream from 'mongochangestream'; import type { Collection } from 'mongodb'; import type { QueueOptions } from 'prom-utils'; import type { Crate, Response } from './crate.js'; import type { ConvertOptions, OptimizationOptions, SyncOptions } from './types.js'; export declare const initSync: (redis: Redis, collection: Collection, crate: Crate, options?: SyncOptions & mongoChangeStream.SyncOptions) => { /** * Process MongoDB change stream for the given collection. */ processChangeStream: (options?: QueueOptions & ChangeStreamOptions & OptimizationOptions) => Promise<{ start: () => Promise<void>; stop: () => Promise<void>; restart: () => Promise<void>; state: Pick<{ get: () => mongoChangeStream.State; change: (newState: mongoChangeStream.State) => void; waitForChange: (...newStates: mongoChangeStream.State[]) => Promise<void>; is: (...states: mongoChangeStream.State[]) => boolean; canChange: (newState: mongoChangeStream.State) => boolean; maybeChange: (newState: mongoChangeStream.State) => boolean; getElapsedTime: () => number; }, "get" | "is">; }>; /** * Run initial collection scan. `options.batchSize` defaults to 500. * Sorting defaults to `_id`. */ runInitialScan: (options?: QueueOptions & ScanOptions) => Promise<{ start: () => Promise<void>; stop: () => Promise<void>; restart: () => Promise<void>; state: Pick<{ get: () => mongoChangeStream.State; change: (newState: mongoChangeStream.State) => void; waitForChange: (...newStates: mongoChangeStream.State[]) => Promise<void>; is: (...states: mongoChangeStream.State[]) => boolean; canChange: (newState: mongoChangeStream.State) => boolean; maybeChange: (newState: mongoChangeStream.State) => boolean; getElapsedTime: () => number; }, "get" | "is">; }>; /** * Convert the given JSON schema to CrateDB table DDL. */ createTableFromSchema: (jsonSchema: object, options?: ConvertOptions) => Promise<Response>; schemaName: string; tableName: string; qualifiedName: string; emitter: import("eventemitter3").EventEmitter<"process" | mongoChangeStream.Events, any>; reset: () => Promise<void>; getCollectionSchema: (db: import("mongodb").Db) => Promise<mongoChangeStream.JSONSchema>; detectSchemaChange: (db: import("mongodb").Db, options?: mongoChangeStream.ChangeOptions) => Promise<{ start: () => void; stop: () => void; }>; detectResync: (resyncCheckInterval?: number) => { start: () => void; stop: () => void; }; keys: { scanCompletedKey: string; lastScanIdKey: string; changeStreamTokenKey: string; schemaKey: string; lastChangeProcessedAtKey: string; lastScanProcessedAtKey: string; resyncKey: string; }; };