import * as amqplib from 'amqplib'; declare class Rabbitr { opts: Rabbitr.IOptions; /** @deprecated */ protected ready: boolean; /** @deprecated */ protected connected: boolean; protected connection: amqplib.Connection; protected log: any; private _openChannels; private _timerChannel; private _backoffChannel; private _publishChannel; private _rpcReturnChannel; _cachedChannel: amqplib.Channel; private connectionPromise; private isShuttingDown; private pendingMessagesCount; private shutdown; private postMessage; /** * An array of channel names used for debug mode. If this value is set, calls to * #subscribe on channels not in this list will be ignored. * * This option is set from the environment variable `RABBITR_DEBUG`. */ private debugChannelsWhitelist; constructor(opts: Rabbitr.IOptions); private initiateConnection; /** method to destroy anything for this instance of rabbitr */ destroy(): Promise; send(topic: string, data: any, opts?: Rabbitr.ISendOptions): Promise; send(topic: string, data: TInput, opts?: Rabbitr.ISendOptions): Promise; subscribe(exchangeNames: string[], queueName: string, opts: Rabbitr.ISubscribeOptions, executorFunc: (data: Rabbitr.IMessage) => void): Promise; subscribe(exchangeNames: string[], queueName: string, opts: Rabbitr.ISubscribeOptions, executorFunc: (data: Rabbitr.IMessage) => void): Promise; private _bindExchangeToQueue; private _timerQueueName; setTimer(topic: string, uniqueID: string, data: TData, ttl: number): Promise; clearTimer(topic: string, uniqueID: string): Promise; private _rpcQueueName; private _createTempQueue; rpcExec(topic: string, data: any, opts?: Rabbitr.IRpcExecOptions): Promise; rpcExec(topic: string, data: TInput, opts?: Rabbitr.IRpcExecOptions): Promise; rpcListener(topic: string, opts: Rabbitr.IRpcListenerOptions, executor: Rabbitr.IRpcListenerExecutor): Promise; rpcListener(topic: string, opts: Rabbitr.IRpcListenerOptions, executor: Rabbitr.IRpcListenerExecutor): Promise; } declare module Rabbitr { /** you MUST provide a 'url' rather than separate 'host', 'password', 'vhost' now */ interface IOptions { url: string; log?: (...args: string[]) => void; connectionOpts?: { heartbeat?: boolean; }; defaultRPCExpiry?: number; } interface ErrorCallback { (err: Error): void; } interface Callback { (err: Error): void; (err: Error, data: T): void; } interface IRpcExecOptions { timeout?: number; context?: any; } interface IRpcListenerOptions { prefetch?: number; } type IRpcListenerExecutor = ((message: IMessage) => PromiseLike) | ((message: IMessage, respond: Callback) => void); interface ISubscribeOptions { prefetch?: number; skipBackoff?: boolean; durable?: boolean; } interface ISendOptions { } interface IMessage { ack(): void; reject(error?: Error): void; topic: string; channel: amqplib.Channel; data: TData; properties?: any; send(topic: string, data: any, cb?: Rabbitr.ErrorCallback, opts?: Rabbitr.ISendOptions): Promise; send(topic: string, data: TInput, cb?: Rabbitr.ErrorCallback, opts?: Rabbitr.ISendOptions): Promise; rpcExec(topic: string, data: any, cb?: Rabbitr.Callback): Promise; rpcExec(topic: string, data: any, opts: Rabbitr.IRpcExecOptions, cb?: Rabbitr.Callback): Promise; rpcExec(topic: string, data: TInput, cb?: Rabbitr.Callback): Promise; rpcExec(topic: string, data: TInput, opts: Rabbitr.IRpcExecOptions, cb?: Rabbitr.Callback): Promise; queue?: { shift: () => void; }; } interface IMessageWithContext extends IMessage { context?: string; } interface IEnvelopedMessage extends IMessage { data: { d: TData; expiration: number; returnQueue: string; context?: any; }; } } export = Rabbitr;