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