/// <reference types="node" />
import { Decoder } from '../RESP/decoder';
import { TypeMapping, RespVersions, RedisArgument } from '../RESP/types';
import { ChannelListeners, PubSubListener, PubSubType, PubSubTypeListeners } from './pub-sub';
import { MonitorCallback } from '.';
export interface CommandOptions<T = TypeMapping> {
    chainId?: symbol;
    asap?: boolean;
    abortSignal?: AbortSignal;
    /**
     * Maps between RESP and JavaScript types
     */
    typeMapping?: T;
    /**
     * Timeout for the command in milliseconds
     */
    timeout?: number;
    /**
     * @internal
     * The slot the command is targeted to (if any)
     */
    slotNumber?: number;
}
export interface CommandToWrite extends CommandWaitingForReply {
    args: ReadonlyArray<RedisArgument>;
    chainId: symbol | undefined;
    abort: {
        signal: AbortSignal;
        listener: () => unknown;
    } | undefined;
    timeout: {
        signal: AbortSignal;
        listener: () => unknown;
        originalTimeout: number | undefined;
    } | undefined;
    slotNumber?: number;
}
interface CommandWaitingForReply {
    resolve(reply?: unknown): void;
    reject(err: unknown): void;
    channelsCounter: number | undefined;
    typeMapping: TypeMapping | undefined;
}
export type OnShardedChannelMoved = (channel: string, listeners: ChannelListeners) => void;
type PushHandler = (pushItems: Array<any>) => boolean;
export default class RedisCommandsQueue {
    #private;
    readonly decoder: Decoder;
    setMaintenanceCommandTimeout(ms: number | undefined): void;
    get isPubSubActive(): boolean;
    constructor(respVersion: RespVersions, maxLength: number | null | undefined, onShardedChannelMoved: OnShardedChannelMoved);
    addPushHandler(handler: PushHandler): void;
    waitForInflightCommandsToComplete(options?: {
        timeoutMs?: number;
        flushOnTimeout?: boolean;
    }): Promise<void>;
    addCommand<T>(args: ReadonlyArray<RedisArgument>, options?: CommandOptions): Promise<T>;
    subscribe<T extends boolean>(type: PubSubType, channels: string | Array<string>, listener: PubSubListener<T>, returnBuffers?: T): Promise<void> | undefined;
    unsubscribe<T extends boolean>(type: PubSubType, channels?: string | Array<string>, listener?: PubSubListener<T>, returnBuffers?: T): Promise<void> | undefined;
    removeAllPubSubListeners(): {
        CHANNELS: PubSubTypeListeners;
        PATTERNS: PubSubTypeListeners;
        SHARDED: PubSubTypeListeners;
    };
    removeShardedPubSubListenersForSlots(slots: Set<number>): {
        SHARDED: Map<string, ChannelListeners>;
    };
    resubscribe(chainId?: symbol): Promise<void[]> | undefined;
    extendPubSubChannelListeners(type: PubSubType, channel: string, listeners: ChannelListeners): Promise<void> | undefined;
    extendPubSubListeners(type: PubSubType, listeners: PubSubTypeListeners): Promise<void> | undefined;
    getPubSubListeners(type: PubSubType): PubSubTypeListeners;
    monitor(callback: MonitorCallback, options?: CommandOptions): Promise<void>;
    resetDecoder(): void;
    reset<T extends TypeMapping>(chainId: symbol, typeMapping?: T): Promise<unknown>;
    isWaitingToWrite(): boolean;
    commandsToWrite(): Generator<readonly RedisArgument[], void, unknown>;
    flushWaitingForReply(err: Error): void;
    flushAll(err: Error): void;
    isEmpty(): boolean;
    /**
     *
     * Extracts commands for the given slots from the toWrite queue.
     * Some commands dont have "slotNumber", which means they are not designated to particular slot/node.
     * We ignore those.
     */
    extractCommandsForSlots(slots: Set<number>): CommandToWrite[];
    /**
    * Gets all commands from the write queue without removing them.
    */
    extractAllCommands(): CommandToWrite[];
    /**
     * Prepends commands to the write queue in reverse.
     */
    prependCommandsToWrite(commands: CommandToWrite[]): void;
}
export {};
//# sourceMappingURL=commands-queue.d.ts.map