import WebSocket from 'ws'; import * as flatbuffers from 'flatbuffers'; import { InlineTable } from '@cubejs-backend/base-driver'; import { QueryResultFormat } from '../codegen'; interface SentMessage { resolve: (value: any) => void; reject: (reason?: any) => void; buffer: Uint8Array; fatalRounds: number; } export type QueryParameter = null | boolean | number | string | Buffer; export type WebSocketQueryOptions = { inlineTables?: InlineTable[]; queryTracingObj?: any; responseFormat: QueryResultFormat; }; interface CubeStoreWebSocket extends WebSocket { readyPromise: Promise; lastHeartBeat: Date; sentMessages: Record; sendAsync: (message: Uint8Array) => Promise; fatalError: Error | null; teardown: () => void; } export declare class WebSocketConnection { protected messageCounter: number; protected readonly maxConnectRetries: number; protected readonly noHeartBeatTimeout: number; protected readonly maxMessageSize: number; protected currentConnectionTry: number; protected webSocket: CubeStoreWebSocket | null; private readonly url; private readonly connectionId; private cubeStoreVersion; private closed; private closedAt; constructor(url: string); protected initWebSocket(): Promise; private retryWaitTime; private sendMessage; protected serializeParameter(builder: flatbuffers.Builder, parameter: unknown): number; query(query: string, parameters: QueryParameter[], options: WebSocketQueryOptions): Promise; getCubeStoreVersion(): Promise; /** * Closes the connection for good. Messages already in flight are given the * chance to be answered -- an eviction can happen mid-query, and failing one * that Cube Store is already working on would fail the request -- so the * socket goes away once the last of them settles, or right away if there are * none. */ close(): void; /** * Gives up on the messages a closed connection was waiting for, so that one * Cube Store never answers costs a query rather than a permanently open * socket. */ private abandonClose; /** * Closes `socket` once nothing is in flight on it. A no-op until close() has * been called, so an ordinary idle connection is left alone. * * Takes the socket rather than reading `this.webSocket`: a late answer can * arrive on a socket the re-send path has already superseded, and that must * not be read as the current connection having drained. */ private closeIfDrained; } export {}; //# sourceMappingURL=WebSocketConnection.d.ts.map