1 | import events = require('events');
|
2 | import { Replies, Options, Message, ServerProperties } from './properties';
|
3 | export * from './properties';
|
4 |
|
5 | export interface Connection extends events.EventEmitter {
|
6 | close(callback?: (err: any) => void): void;
|
7 | createChannel(callback: (err: any, channel: Channel) => void): void;
|
8 | createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void;
|
9 | connection: {
|
10 | serverProperties: ServerProperties;
|
11 | };
|
12 | }
|
13 |
|
14 | export interface Channel extends events.EventEmitter {
|
15 | connection: Connection;
|
16 |
|
17 | close(callback: (err: any) => void): void;
|
18 |
|
19 | assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
|
20 | checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
|
21 |
|
22 | deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err: any, ok: Replies.DeleteQueue) => void): void;
|
23 | purgeQueue(queue: string, callback?: (err: any, ok: Replies.PurgeQueue) => void): void;
|
24 |
|
25 | bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
26 | unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
27 |
|
28 | assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void;
|
29 | checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
30 |
|
31 | deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void;
|
32 |
|
33 | bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
34 | unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
35 |
|
36 | publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
37 | sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
38 |
|
39 | consume(queue: string, onMessage: (msg: Message | null) => void, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void;
|
40 |
|
41 | cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
42 | get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | false) => void): void;
|
43 |
|
44 | ack(message: Message, allUpTo?: boolean): void;
|
45 | ackAll(): void;
|
46 |
|
47 | nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
48 | nackAll(requeue?: boolean): void;
|
49 | reject(message: Message, requeue?: boolean): void;
|
50 |
|
51 | prefetch(count: number, global?: boolean): void;
|
52 | recover(callback?: (err: any, ok: Replies.Empty) => void): void;
|
53 | }
|
54 |
|
55 | export interface ConfirmChannel extends Channel {
|
56 | publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
|
57 | sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
|
58 |
|
59 | waitForConfirms(callback?: (err: any) => void): void;
|
60 | }
|
61 |
|
62 | export const credentials: {
|
63 | amqplain(username: string, password: string): {
|
64 | mechanism: string;
|
65 | response(): Buffer;
|
66 | username: string;
|
67 | password: string;
|
68 | };
|
69 | external(): {
|
70 | mechanism: string;
|
71 | response(): Buffer;
|
72 | };
|
73 | plain(username: string, password: string): {
|
74 | mechanism: string;
|
75 | response(): Buffer;
|
76 | username: string;
|
77 | password: string;
|
78 | };
|
79 | };
|
80 |
|
81 | export function connect(callback: (err: any, connection: Connection) => void): void;
|
82 | export function connect(url: string | Options.Connect, callback: (err: any, connection: Connection) => void): void;
|
83 | export function connect(url: string | Options.Connect, socketOptions: any, callback: (err: any, connection: Connection) => void): void;
|