UNPKG

harperdb

Version:

HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.

72 lines (71 loc) 3.19 kB
/** * This is the entry module is responsible for replicating data between nodes. It is a source for tables that are replicated * A typical exchange should look like: * 1. Node A connects to node B, and sends its node name and the database name (and the mapping of its node id to short ids?) * 2. Node B sends back its node name and the mapping of its node id to short ids * 3. Node A sends a subscription request to node B * 3a. Node B may also send a subscription request to node A * 4. Node B sends back the table names and structures * 5. Node B sends back the audit records */ export { startOnMainThread } from './subscriptionManager.ts'; import type { Database } from 'lmdb'; export declare const servers: any[]; export declare const replicationCertificateAuthorities: Set<unknown>; /** * Build mTLS configuration for replication server with certificate verification support * @param replicationOptions - Replication configuration options * @returns mTLS configuration object (always enabled for replication) */ export declare function buildReplicationMtlsConfig(replicationOptions: any): any; /** * Start the replication server. This will start a WebSocket server that will accept replication requests from other nodes. * @param options */ export declare function start(options: any): void; export declare function monitorNodeCAs(listener: () => void): void; export declare function disableReplication(disabled?: boolean): void; export declare let enabledDatabases: any; /** * Get/create a replication resource that can be assigned as a source to tables * @param tableName * @param dbName */ export declare function setReplicator(dbName: string, table: any, options: any): void; export declare function sendOperationToNode(node: any, operation: any, options: any): Promise<unknown>; /** * Subscribe to a node for a database, getting the necessary connection and subscription and signaling the start of the subscription * @param request */ export declare function subscribeToNode(request: any): void; export declare function unsubscribeFromNode({ url, nodes, database }: { url: any; nodes: any; database: any; }): Promise<void>; /** Attempt to figure out the host/node name, using direct or indirect settings * @returns {string} */ export declare function getThisNodeName(): any; export declare function clearThisNodeName(): void; export declare function getThisNodeId(auditStore: any): any; export declare function getThisNodeUrl(): any; export declare function hostnameToUrl(hostname: any): string; export declare function urlToNodeName(nodeUrl: any): string; /** * Iterate through all the databases and tables that are replicated, both those that exist now, and future databases that * are added or removed, calling the callback for each * @param options * @param callback */ export declare function forEachReplicatedDatabase(options: any, callback: any): { remove(): void; }; /** * Get the last time that an audit record was added to the audit store * @param auditStore */ export declare function lastTimeInAuditStore(auditStore: Database): any; export declare function replicateOperation(req: any): Promise<{ message: string; }>;