/// <reference types="node" />
import EventEmitter from 'events';
import { LastTimeRecords } from './LastTimeRecords';
import { RecordsBuffer } from './RecordsBuffer';
import { VirtualTimeObj } from './VirtualTimeObj';
import { IEcho, ILoggerEx, ISender, ISenderConfig, IStreamConfig, TDbRecord, TEventRecord } from './interfaces';
import { DbMsSql } from './db/DbMsSql';
import { DbPostgres } from './db/DbPostgres';
export interface IStreamConstructorOptions {
    streamConfig: IStreamConfig;
    senderConfig: ISenderConfig;
    serviceName: string;
    redis: {
        host: string;
        port: string | number;
    };
    logger: ILoggerEx;
    echo: IEcho;
    exitOnError: Function;
    eventEmitter: EventEmitter;
    useStartTimeFromRedisCache: boolean;
    speed?: number;
    loopTime?: string | number;
    prepareEvent?: Function;
    tsFieldToMillis?: Function;
    millis2dbFn?: Function;
    testMode?: boolean;
}
export declare class Stream {
    readonly bufferLookAheadMs: number;
    lastRecordTs: number;
    recordsBuffer: RecordsBuffer;
    lastTimeRecords: LastTimeRecords;
    virtualTimeObj: VirtualTimeObj;
    readonly options: IStreamConstructorOptions;
    sender: ISender;
    readonly sessionId: string;
    db: DbMsSql | DbPostgres;
    locked: boolean;
    private loopTimeMillis;
    private busy;
    private sendTimer;
    private readonly sendInterval;
    private totalRowsSent;
    private readonly tsFieldToMillis;
    private readonly prepareEvent;
    private readonly millis2dbFn;
    private initialized;
    private isFirstLoad;
    private maxBufferSize;
    private prefix;
    constructor(options: IStreamConstructorOptions);
    init(): Promise<Stream | undefined>;
    start(): Promise<Stream>;
    findEndIndex(): number;
    static packetInfo(count: number, fromRecord?: TEventRecord | null, toRecord?: TEventRecord | null): string;
    prepareEventsPacket(dbRecordOrRecordset: TDbRecord[]): Promise<TEventRecord[]>;
    _addPortionToBuffer(recordset: TDbRecord[]): Promise<void>;
    _loadNextPortion(): Promise<void>;
    _fetchLoop(): void;
    _printInfoLoop(): void;
    _sendPacket(eventsPacket: TEventRecord[]): Promise<{
        debugMessage: string;
        isError?: boolean;
    }>;
    _send(): Promise<void>;
    _sendLoop(): Promise<any>;
    setEventCallback(eventCallback: Function): void;
    lock(): void;
    unLock(): void;
}
//# sourceMappingURL=Stream.d.ts.map