-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
56 lines (49 loc) · 2.13 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/// <reference types="amqplib" />
/// <reference types="node" />
import { Options, Connection, Channel } from 'amqplib';
import { Broker } from 'smqp';
export interface FakeAmqplibChannel extends Channel {
/** Channel name and identifier, for faking purposes */
_channelName: string;
_broker: Broker;
_version: number;
new (broker: Broker, connection: FakeAmqplibConnection): FakeAmqplibChannel;
get _closed(): boolean;
}
export interface FakeAmqplibConnection extends Connection {
_channels: FakeAmqplibChannel[];
_url: URL;
/** Connection identifier, for faking purposes */
_id: string;
_broker: Broker;
_version: number;
new (broker: Broker, version: number, amqpUrl: string, options?: any): FakeAmqplibConnection;
get _closed(): boolean;
}
interface SocketOptions {
host?: string;
keepAlive?: boolean;
keepAliveDelay?: number;
noDelay?: boolean;
port?: number;
serverName?: string;
timeout?: number;
[x: string]: any;
}
type connectCallback = (err: Error, connection: FakeAmqplibConnection) => void;
export class FakeAmqplib {
connections: FakeAmqplibConnection[];
constructor(version?: number);
connect(url: string | Options.Connect, socketOptions?: SocketOptions): Promise<FakeAmqplibConnection>;
connect(url: string | Options.Connect, socketOptions: SocketOptions, callback: connectCallback): void;
connect(url: string | Options.Connect, callback: (err: Error, connection: FakeAmqplibConnection) => void): void;
connectSync(url: string | Options.Connect, socketOptions?: SocketOptions): FakeAmqplibConnection;
resetMock(): void;
setVersion(minorVersion: number): void;
}
export function connect(url: string | Options.Connect, socketOptions?: SocketOptions): Promise<FakeAmqplibConnection>;
export function connect(url: string | Options.Connect, socketOptions: SocketOptions, callback: connectCallback): void;
export function connect(url: string | Options.Connect, callback: connectCallback): void;
export function connectSync(url: string | Options.Connect, socketOptions?: SocketOptions): FakeAmqplibConnection;
export function resetMock(): void;
export function setVersion(minorVersion: number): void;