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