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