1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import events = require('events');
|
17 | import tls = require('tls');
|
18 |
|
19 | export const version: string;
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export const BAD_AUTHENTICATION: string;
|
25 | export const BAD_JSON: string;
|
26 | export const BAD_MSG: string;
|
27 | export const BAD_REPLY: string;
|
28 | export const BAD_SUBJECT: string;
|
29 | export const CLIENT_CERT_REQ: string;
|
30 | export const CONN_CLOSED: string;
|
31 | export const CONN_ERR: string;
|
32 | export const INVALID_ENCODING: string;
|
33 | export const NATS_PROTOCOL_ERR: string;
|
34 | export const NON_SECURE_CONN_REQ: string;
|
35 | export const PERMISSIONS_ERR: string;
|
36 | export const REQ_TIMEOUT: string;
|
37 | export const SECURE_CONN_REQ: string;
|
38 | export const STALE_CONNECTION_ERR: string;
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | export function createInbox(): string;
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | export function connect(opts: ClientOpts): Client;
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | export function connect(port: number): Client;
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | export function connect(url: string): Client;
|
65 |
|
66 | export interface ClientOpts {
|
67 | url?: string,
|
68 | user?: string,
|
69 | pass?: string,
|
70 | verbose?: boolean,
|
71 | pedantic?: boolean,
|
72 | reconnect?: boolean,
|
73 | maxReconnectAttempts?: number,
|
74 | reconnectTimeWait?: number,
|
75 | servers?: Array<string>,
|
76 | noRandomize?: boolean,
|
77 | encoding?: BufferEncoding,
|
78 | tls?: boolean | tls.TlsOptions,
|
79 | name?: string,
|
80 | yieldTime?: number,
|
81 | waitOnFirstConnect?: boolean,
|
82 | json?: boolean,
|
83 | preserveBuffers?: boolean,
|
84 | token?: string,
|
85 | pingInterval?: number,
|
86 | maxPingOut?: number,
|
87 | useOldRequestStyle?: boolean
|
88 | }
|
89 |
|
90 | export interface SubscribeOptions {
|
91 | queue?: string,
|
92 | max?: number
|
93 | }
|
94 |
|
95 | declare class Client extends events.EventEmitter {
|
96 | |
97 |
|
98 |
|
99 | createInbox(): string;
|
100 |
|
101 | |
102 |
|
103 |
|
104 | close():void;
|
105 |
|
106 | |
107 |
|
108 |
|
109 |
|
110 | flush(callback?: Function):void;
|
111 |
|
112 | |
113 |
|
114 |
|
115 | publish(callback: Function):void;
|
116 | publish(subject: string, callback: Function):void;
|
117 | publish(subject: string, msg: string | Buffer, callback: Function):void;
|
118 | publish(subject: string, msg?: string | Buffer, reply?: string, callback?: Function):void;
|
119 |
|
120 | |
121 |
|
122 |
|
123 |
|
124 | subscribe(subject: string, callback: Function): number;
|
125 | subscribe(subject: string, opts: SubscribeOptions, callback: Function): number;
|
126 |
|
127 | |
128 |
|
129 |
|
130 | unsubscribe(sid: number, max?: number):void;
|
131 |
|
132 | |
133 |
|
134 |
|
135 | timeout(sid: number, timeout: number, expected: number, callback: (sid: number) => void):void;
|
136 |
|
137 | |
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | request(subject: string, callback: Function): number;
|
145 | request(subject: string, msg: string | Buffer, callback: Function): number;
|
146 | request(subject: string, msg?: string, options?: SubscribeOptions, callback?: Function): number;
|
147 |
|
148 | |
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 | requestOne(subject: string, msg: string | Buffer, options?: SubscribeOptions, timeout?: number, callback?:Function) : number
|
157 |
|
158 | |
159 |
|
160 |
|
161 | numSubscriptions(): number;
|
162 | }
|
163 |
|
164 | declare class NatsError implements Error {
|
165 | public name: string;
|
166 | public message: string;
|
167 | public code: string;
|
168 | public chainedError: Error;
|
169 |
|
170 | constructor(message:string, code:string, chainedError?:Error);
|
171 | }
|