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