-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
148 lines (122 loc) · 3 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Actually options are different for Queue, Exchange, Channel and so on...
// Here we just put all the things into one object and make all props non mandatory
// So, one interface can work for various things
declare interface OptionsConf {
exclusive?: boolean,
durable?: boolean,
arguments?: any,
expires?: number,
deadLetterExchange?: string,
deadLetterRoutingKey?: string,
maxLength?: number,
maxPriority?: number,
overflow?: boolean,
queueMode?: string,
autoDelete?: boolean,
consumerTag?: string,
noLocal?: boolean
}
declare interface QueueConf {
name: string,
options?: OptionsConf
}
declare interface ExchangeConf {
name: string,
type: string,
options?: OptionsConf
}
declare interface BindingConf {
enabled?: boolean,
pattern?: string,
options?: OptionsConf
}
declare interface ConnectionConf {
host: string,
port: number,
ssl: boolean,
username: string,
password: string,
vhost?: string,
heartbeat?: number
}
declare interface ChannelConf {
exchange: ExchangeConf
queue?: QueueConf,
binding?: BindingConf,
topic?: string,
options?: OptionsConf,
msg?: any,
autoConsume?: boolean,
prefetch?: number,
}
declare interface AmqpConfig {
connection: ConnectionConf,
channel: ChannelConf
}
declare class AMQPPool {
constructor(amqpConfigArray: Array<AmqpConfig>);
start(msgCacheInterval?: number): void;
stop(cbFn: Function): void;
addConnection(connection: ConnectionConf): void;
publish(
msg: any,
filter: string,
topic: string,
props: any
): void;
ack(msg: any): void;
nack(msg: any): void;
getAliveChannels(): Array<Channel>;
getChannelByHash(
connectionIndex: number,
hash: string
): Channel;
getAllChannels(): Array<Channel>;
getChannelById(id: string): Array<Channel>;
getConnectionIndexByUrl(url: string): number | false;
createConnection(
url: string,
connnection: ConnectionConf
): number;
createChannel(
connectionIndex: number,
channel: ChannelConf
): void;
}
declare class Channel {
constructor(
connection: ConnectionConf,
channel: ChannelConf
);
isConsumable(): boolean;
alive(): boolean;
alive(isAlive: boolean): void;
queueOptions(): OptionsConf;
create(): boolean;
publish(
msg: any,
topic: string,
options: OptionsConf
): void;
consume(quueueName: string): void;
ack(msg: any): void;
nack(msg: any): void;
hasCachedAck(): boolean;
sendToQueue(
queue: QueueConf,
msg: any
): void;
}
declare class Connection {
constructor(
url: string,
connection: ConnectionConf
);
alive(isAlive: boolean): void;
alive(): boolean;
start(): void;
connection(): void;
addChannel(channel: ChannelConf): void;
removeChannel(channel: ChannelConf): void;
disconnect(): void;
}