@maiyunnet/kebab 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.VSCodeCounter/2025-02-14_14-46-44/details.md +82 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff-details.md +15 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.csv +2 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.md +19 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.txt +22 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.csv +69 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.json +1 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.md +48 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.txt +118 -0
- package/.vscode/tasks.json +15 -0
- package/LICENSE +201 -0
- package/README.md +201 -0
- package/bin/kebab.js +2 -0
- package/eslint.config.js +22 -0
- package/index.js +19 -0
- package/index.ts +33 -0
- package/lib/buffer.js +108 -0
- package/lib/buffer.ts +152 -0
- package/lib/captcha/zcool-addict-italic.ttf +0 -0
- package/lib/captcha.js +71 -0
- package/lib/captcha.ts +63 -0
- package/lib/consistent.js +171 -0
- package/lib/consistent.ts +219 -0
- package/lib/core.js +663 -0
- package/lib/core.ts +880 -0
- package/lib/crypto.js +256 -0
- package/lib/crypto.ts +384 -0
- package/lib/db.js +521 -0
- package/lib/db.ts +719 -0
- package/lib/dns.js +321 -0
- package/lib/dns.ts +405 -0
- package/lib/fs.js +405 -0
- package/lib/fs.ts +527 -0
- package/lib/jwt.js +223 -0
- package/lib/jwt.ts +276 -0
- package/lib/kv.js +1004 -0
- package/lib/kv.ts +1489 -0
- package/lib/lan.js +99 -0
- package/lib/lan.ts +87 -0
- package/lib/net/cacert.pem +3480 -0
- package/lib/net/formdata.js +137 -0
- package/lib/net/formdata.ts +166 -0
- package/lib/net/request.js +102 -0
- package/lib/net/request.ts +150 -0
- package/lib/net/response.js +28 -0
- package/lib/net/response.ts +59 -0
- package/lib/net.js +462 -0
- package/lib/net.ts +662 -0
- package/lib/s3.js +180 -0
- package/lib/s3.ts +235 -0
- package/lib/scan.js +276 -0
- package/lib/scan.ts +364 -0
- package/lib/session.js +177 -0
- package/lib/session.ts +230 -0
- package/lib/sql.js +818 -0
- package/lib/sql.ts +1151 -0
- package/lib/ssh/sftp.js +373 -0
- package/lib/ssh/sftp.ts +508 -0
- package/lib/ssh/shell.js +109 -0
- package/lib/ssh/shell.ts +123 -0
- package/lib/ssh.js +171 -0
- package/lib/ssh.ts +191 -0
- package/lib/text/tld.json +1 -0
- package/lib/text.js +452 -0
- package/lib/text.ts +607 -0
- package/lib/time.js +216 -0
- package/lib/time.ts +254 -0
- package/lib/ws.js +373 -0
- package/lib/ws.ts +523 -0
- package/lib/zip.js +381 -0
- package/lib/zip.ts +447 -0
- package/lib/zlib.js +289 -0
- package/lib/zlib.ts +350 -0
- package/main.js +51 -0
- package/main.ts +27 -0
- package/package.json +37 -0
- package/sys/child.js +585 -0
- package/sys/child.ts +678 -0
- package/sys/cmd.js +226 -0
- package/sys/cmd.ts +225 -0
- package/sys/ctr.js +608 -0
- package/sys/ctr.ts +904 -0
- package/sys/master.js +314 -0
- package/sys/master.ts +355 -0
- package/sys/mod.js +1273 -0
- package/sys/mod.ts +1871 -0
- package/sys/route.js +922 -0
- package/sys/route.ts +1113 -0
- package/types/index.d.ts +283 -0
- package/www/example/ctr/main.js +42 -0
- package/www/example/ctr/main.ts +9 -0
- package/www/example/ctr/middle.js +57 -0
- package/www/example/ctr/middle.ts +26 -0
- package/www/example/ctr/test.js +2818 -0
- package/www/example/ctr/test.ts +3218 -0
- package/www/example/data/locale/en.test.json +8 -0
- package/www/example/data/locale/index.html +1 -0
- package/www/example/data/locale/ja.test.json +8 -0
- package/www/example/data/locale/sc.test.json +8 -0
- package/www/example/data/locale/tc.test.json +8 -0
- package/www/example/data/test.zip +0 -0
- package/www/example/kebab.json +24 -0
- package/www/example/mod/test.js +49 -0
- package/www/example/mod/test.ts +47 -0
- package/www/example/mod/testdata.js +11 -0
- package/www/example/mod/testdata.ts +30 -0
- package/www/example/route.json +6 -0
- package/www/example/view/test.ejs +11 -0
- package/www/example/ws/mproxy.js +49 -0
- package/www/example/ws/mproxy.ts +16 -0
- package/www/example/ws/rproxy.js +47 -0
- package/www/example/ws/rproxy.ts +14 -0
- package/www/example/ws/test.js +68 -0
- package/www/example/ws/test.ts +36 -0
package/lib/kv.js
ADDED
|
@@ -0,0 +1,1004 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Connection = exports.Pool = void 0;
|
|
37
|
+
exports.get = get;
|
|
38
|
+
exports.getConnectionList = getConnectionList;
|
|
39
|
+
const redis = __importStar(require("@litert/redis"));
|
|
40
|
+
const time = __importStar(require("~/lib/time"));
|
|
41
|
+
const text = __importStar(require("~/lib/text"));
|
|
42
|
+
const connections = [];
|
|
43
|
+
async function checkConnection() {
|
|
44
|
+
const now = time.stamp();
|
|
45
|
+
for (let i = 0; i < connections.length; ++i) {
|
|
46
|
+
const connection = connections[i];
|
|
47
|
+
if (connection.isLost()) {
|
|
48
|
+
await connection.end();
|
|
49
|
+
connections.splice(i, 1);
|
|
50
|
+
--i;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (connection.isUsing()) {
|
|
54
|
+
if (connection.getLast() <= now - 180) {
|
|
55
|
+
console.log(`[kv] [error] There is a transactional connection[${i}] that is not closed.`);
|
|
56
|
+
await connection.end();
|
|
57
|
+
connections.splice(i, 1);
|
|
58
|
+
--i;
|
|
59
|
+
}
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (connection.getLast() > now - 180) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
await connection.end();
|
|
66
|
+
connections.splice(i, 1);
|
|
67
|
+
--i;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
setTimeout(function () {
|
|
71
|
+
checkConnection().catch(e => { console.log('[KV]', e); });
|
|
72
|
+
}, 30000);
|
|
73
|
+
}
|
|
74
|
+
setTimeout(function () {
|
|
75
|
+
checkConnection().catch(e => { console.log('[KV]', e); });
|
|
76
|
+
}, 30000);
|
|
77
|
+
class Pool {
|
|
78
|
+
constructor(ctr, etc) {
|
|
79
|
+
if (etc) {
|
|
80
|
+
this._etc = etc;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this._etc = ctr.getPrototype('_config').kv;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async set(key, val, ttl = 0, mod = '') {
|
|
87
|
+
const conn = await this._getConnection();
|
|
88
|
+
if (!conn) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
const r = await conn.set(key, val, ttl, mod, this._etc);
|
|
92
|
+
conn.used();
|
|
93
|
+
return r;
|
|
94
|
+
}
|
|
95
|
+
async add(key, val, ttl = 0) {
|
|
96
|
+
const conn = await this._getConnection();
|
|
97
|
+
if (!conn) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const r = await conn.add(key, val, ttl, this._etc);
|
|
101
|
+
conn.used();
|
|
102
|
+
return r;
|
|
103
|
+
}
|
|
104
|
+
async replace(key, val, ttl = 0) {
|
|
105
|
+
const conn = await this._getConnection();
|
|
106
|
+
if (!conn) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const r = await conn.replace(key, val, ttl, this._etc);
|
|
110
|
+
conn.used();
|
|
111
|
+
return r;
|
|
112
|
+
}
|
|
113
|
+
async append(key, val) {
|
|
114
|
+
const conn = await this._getConnection();
|
|
115
|
+
if (!conn) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const r = await conn.append(key, val, this._etc);
|
|
119
|
+
conn.used();
|
|
120
|
+
return r;
|
|
121
|
+
}
|
|
122
|
+
async prepend(key, val) {
|
|
123
|
+
const conn = await this._getConnection();
|
|
124
|
+
if (!conn) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
const r = await conn.prepend(key, val, this._etc);
|
|
128
|
+
conn.used();
|
|
129
|
+
return r;
|
|
130
|
+
}
|
|
131
|
+
async exists(keys) {
|
|
132
|
+
const conn = await this._getConnection();
|
|
133
|
+
if (!conn) {
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
const r = await conn.exists(keys, this._etc);
|
|
137
|
+
conn.used();
|
|
138
|
+
return r;
|
|
139
|
+
}
|
|
140
|
+
async get(key) {
|
|
141
|
+
const conn = await this._getConnection();
|
|
142
|
+
if (!conn) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const r = await conn.get(key, this._etc);
|
|
146
|
+
conn.used();
|
|
147
|
+
return r;
|
|
148
|
+
}
|
|
149
|
+
async ttl(key) {
|
|
150
|
+
const conn = await this._getConnection();
|
|
151
|
+
if (!conn) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
const r = await conn.ttl(key, this._etc);
|
|
155
|
+
conn.used();
|
|
156
|
+
return r;
|
|
157
|
+
}
|
|
158
|
+
async pttl(key) {
|
|
159
|
+
const conn = await this._getConnection();
|
|
160
|
+
if (!conn) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const r = await conn.pttl(key, this._etc);
|
|
164
|
+
conn.used();
|
|
165
|
+
return r;
|
|
166
|
+
}
|
|
167
|
+
async mSet(rows) {
|
|
168
|
+
const conn = await this._getConnection();
|
|
169
|
+
if (!conn) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
const r = await conn.mSet(rows, this._etc);
|
|
173
|
+
conn.used();
|
|
174
|
+
return r;
|
|
175
|
+
}
|
|
176
|
+
async mGet(keys) {
|
|
177
|
+
const conn = await this._getConnection();
|
|
178
|
+
if (conn) {
|
|
179
|
+
const r = await conn.mGet(keys, this._etc);
|
|
180
|
+
conn.used();
|
|
181
|
+
return r;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const rtn = {};
|
|
185
|
+
for (const key of keys) {
|
|
186
|
+
rtn[key] = null;
|
|
187
|
+
}
|
|
188
|
+
return rtn;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async getJson(key) {
|
|
192
|
+
const conn = await this._getConnection();
|
|
193
|
+
if (!conn) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
const r = await conn.getJson(key, this._etc);
|
|
197
|
+
conn.used();
|
|
198
|
+
return r;
|
|
199
|
+
}
|
|
200
|
+
async del(keys) {
|
|
201
|
+
const conn = await this._getConnection();
|
|
202
|
+
if (!conn) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
const r = await conn.del(keys, this._etc);
|
|
206
|
+
conn.used();
|
|
207
|
+
return r;
|
|
208
|
+
}
|
|
209
|
+
async incr(key, num = 1) {
|
|
210
|
+
const conn = await this._getConnection();
|
|
211
|
+
if (!conn) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const r = await conn.incr(key, num, this._etc);
|
|
215
|
+
conn.used();
|
|
216
|
+
return r;
|
|
217
|
+
}
|
|
218
|
+
async decr(key, num = 1) {
|
|
219
|
+
const conn = await this._getConnection();
|
|
220
|
+
if (!conn) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
const r = await conn.decr(key, num, this._etc);
|
|
224
|
+
conn.used();
|
|
225
|
+
return r;
|
|
226
|
+
}
|
|
227
|
+
async expire(key, ttl) {
|
|
228
|
+
const conn = await this._getConnection();
|
|
229
|
+
if (!conn) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
const r = await conn.expire(key, ttl, this._etc);
|
|
233
|
+
conn.used();
|
|
234
|
+
return r;
|
|
235
|
+
}
|
|
236
|
+
async keys(pattern) {
|
|
237
|
+
const conn = await this._getConnection();
|
|
238
|
+
if (!conn) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
const r = await conn.keys(pattern, this._etc);
|
|
242
|
+
conn.used();
|
|
243
|
+
return r;
|
|
244
|
+
}
|
|
245
|
+
async scan(cursor = 0, pattern = '*', count = 10) {
|
|
246
|
+
const conn = await this._getConnection();
|
|
247
|
+
if (!conn) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
const r = await conn.scan(cursor, pattern, count, this._etc);
|
|
251
|
+
conn.used();
|
|
252
|
+
return r;
|
|
253
|
+
}
|
|
254
|
+
async flushDb() {
|
|
255
|
+
const conn = await this._getConnection();
|
|
256
|
+
if (!conn) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
const r = await conn.flushDb();
|
|
260
|
+
conn.used();
|
|
261
|
+
return r;
|
|
262
|
+
}
|
|
263
|
+
async ping() {
|
|
264
|
+
const conn = await this._getConnection();
|
|
265
|
+
if (!conn) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
const r = await conn.ping();
|
|
269
|
+
conn.used();
|
|
270
|
+
return r;
|
|
271
|
+
}
|
|
272
|
+
async hSet(key, field, val, mod = '') {
|
|
273
|
+
const conn = await this._getConnection();
|
|
274
|
+
if (!conn) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
const r = await conn.hSet(key, field, val, mod, this._etc);
|
|
278
|
+
conn.used();
|
|
279
|
+
return r;
|
|
280
|
+
}
|
|
281
|
+
async hMSet(key, rows) {
|
|
282
|
+
const conn = await this._getConnection();
|
|
283
|
+
if (!conn) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
const r = await conn.hMSet(key, rows, this._etc);
|
|
287
|
+
conn.used();
|
|
288
|
+
return r;
|
|
289
|
+
}
|
|
290
|
+
async hGet(key, field) {
|
|
291
|
+
const conn = await this._getConnection();
|
|
292
|
+
if (!conn) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
const r = await conn.hGet(key, field, this._etc);
|
|
296
|
+
conn.used();
|
|
297
|
+
return r;
|
|
298
|
+
}
|
|
299
|
+
async hGetJson(key, field) {
|
|
300
|
+
const conn = await this._getConnection();
|
|
301
|
+
if (!conn) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
const r = await conn.hGetJson(key, field, this._etc);
|
|
305
|
+
conn.used();
|
|
306
|
+
return r;
|
|
307
|
+
}
|
|
308
|
+
async hMGet(key, fields) {
|
|
309
|
+
const conn = await this._getConnection();
|
|
310
|
+
if (conn) {
|
|
311
|
+
const r = await conn.hMGet(key, fields, this._etc);
|
|
312
|
+
conn.used();
|
|
313
|
+
return r;
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
const rtn = {};
|
|
317
|
+
for (const field of fields) {
|
|
318
|
+
rtn[field] = null;
|
|
319
|
+
}
|
|
320
|
+
return rtn;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
async hGetAll(key) {
|
|
324
|
+
const conn = await this._getConnection();
|
|
325
|
+
if (!conn) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
const r = await conn.hGetAll(key, this._etc);
|
|
329
|
+
conn.used();
|
|
330
|
+
return r;
|
|
331
|
+
}
|
|
332
|
+
async hDel(key, fields) {
|
|
333
|
+
const conn = await this._getConnection();
|
|
334
|
+
if (!conn) {
|
|
335
|
+
return 0;
|
|
336
|
+
}
|
|
337
|
+
const r = await conn.hDel(key, fields, this._etc);
|
|
338
|
+
conn.used();
|
|
339
|
+
return r;
|
|
340
|
+
}
|
|
341
|
+
async hExists(key, field) {
|
|
342
|
+
const conn = await this._getConnection();
|
|
343
|
+
if (!conn) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
const r = await conn.hExists(key, field, this._etc);
|
|
347
|
+
conn.used();
|
|
348
|
+
return r;
|
|
349
|
+
}
|
|
350
|
+
async hIncr(key, field, increment) {
|
|
351
|
+
const conn = await this._getConnection();
|
|
352
|
+
if (!conn) {
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
const r = await conn.hIncr(key, field, increment, this._etc);
|
|
356
|
+
conn.used();
|
|
357
|
+
return r;
|
|
358
|
+
}
|
|
359
|
+
async hKeys(key) {
|
|
360
|
+
const conn = await this._getConnection();
|
|
361
|
+
if (!conn) {
|
|
362
|
+
return [];
|
|
363
|
+
}
|
|
364
|
+
const r = await conn.hKeys(key, this._etc);
|
|
365
|
+
conn.used();
|
|
366
|
+
return r;
|
|
367
|
+
}
|
|
368
|
+
async lPush(key, values) {
|
|
369
|
+
const conn = await this._getConnection();
|
|
370
|
+
if (!conn) {
|
|
371
|
+
return 0;
|
|
372
|
+
}
|
|
373
|
+
const r = await conn.lPush(key, values, this._etc);
|
|
374
|
+
conn.used();
|
|
375
|
+
return r;
|
|
376
|
+
}
|
|
377
|
+
async rPush(key, values) {
|
|
378
|
+
const conn = await this._getConnection();
|
|
379
|
+
if (!conn) {
|
|
380
|
+
return 0;
|
|
381
|
+
}
|
|
382
|
+
const r = await conn.rPush(key, values, this._etc);
|
|
383
|
+
conn.used();
|
|
384
|
+
return r;
|
|
385
|
+
}
|
|
386
|
+
async bLMove(sourceKey, destKey, soo, deo, timeout) {
|
|
387
|
+
const conn = await this._getConnection();
|
|
388
|
+
if (!conn) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
const r = await conn.bLMove(sourceKey, destKey, soo, deo, timeout, this._etc);
|
|
392
|
+
conn.used();
|
|
393
|
+
return r;
|
|
394
|
+
}
|
|
395
|
+
async lPop(key) {
|
|
396
|
+
const conn = await this._getConnection();
|
|
397
|
+
if (!conn) {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
const r = await conn.lPop(key, this._etc);
|
|
401
|
+
conn.used();
|
|
402
|
+
return r;
|
|
403
|
+
}
|
|
404
|
+
async rPop(key) {
|
|
405
|
+
const conn = await this._getConnection();
|
|
406
|
+
if (!conn) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
const r = await conn.rPop(key, this._etc);
|
|
410
|
+
conn.used();
|
|
411
|
+
return r;
|
|
412
|
+
}
|
|
413
|
+
async bRPop(key, timeout) {
|
|
414
|
+
const conn = await this._getConnection();
|
|
415
|
+
if (!conn) {
|
|
416
|
+
return {};
|
|
417
|
+
}
|
|
418
|
+
const r = await conn.bRPop(key, timeout, this._etc);
|
|
419
|
+
conn.used();
|
|
420
|
+
return r;
|
|
421
|
+
}
|
|
422
|
+
async lRange(key, start, stop) {
|
|
423
|
+
const conn = await this._getConnection();
|
|
424
|
+
if (!conn) {
|
|
425
|
+
return [];
|
|
426
|
+
}
|
|
427
|
+
const r = await conn.lRange(key, start, stop, this._etc);
|
|
428
|
+
conn.used();
|
|
429
|
+
return r;
|
|
430
|
+
}
|
|
431
|
+
async lLen(key) {
|
|
432
|
+
const conn = await this._getConnection();
|
|
433
|
+
if (!conn) {
|
|
434
|
+
return 0;
|
|
435
|
+
}
|
|
436
|
+
const r = await conn.lLen(key, this._etc);
|
|
437
|
+
conn.used();
|
|
438
|
+
return r;
|
|
439
|
+
}
|
|
440
|
+
async _getConnection() {
|
|
441
|
+
let conn;
|
|
442
|
+
for (const connection of connections) {
|
|
443
|
+
const etc = connection.getEtc();
|
|
444
|
+
if (connection.isLost() ||
|
|
445
|
+
connection.isUsing() ||
|
|
446
|
+
(etc.host !== this._etc.host) ||
|
|
447
|
+
(etc.port !== this._etc.port) ||
|
|
448
|
+
(etc.index !== this._etc.index)) {
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
connection.refreshLast();
|
|
452
|
+
connection.setUsing();
|
|
453
|
+
conn = connection;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
if (!conn) {
|
|
457
|
+
const link = redis.createCommandClient({
|
|
458
|
+
'host': this._etc.host,
|
|
459
|
+
'port': this._etc.port
|
|
460
|
+
});
|
|
461
|
+
try {
|
|
462
|
+
await link.connect();
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
if (this._etc.user || this._etc.pwd) {
|
|
468
|
+
try {
|
|
469
|
+
await link.auth(this._etc.user + this._etc.pwd);
|
|
470
|
+
}
|
|
471
|
+
catch {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
await link.select(this._etc.index);
|
|
476
|
+
conn = new Connection(this._etc, link);
|
|
477
|
+
conn.refreshLast();
|
|
478
|
+
conn.setUsing();
|
|
479
|
+
link.on('error', function (err) {
|
|
480
|
+
conn.setLost();
|
|
481
|
+
console.log('[KV] [ERROR]', err);
|
|
482
|
+
}).on('close', () => {
|
|
483
|
+
conn.setLost();
|
|
484
|
+
});
|
|
485
|
+
connections.push(conn);
|
|
486
|
+
}
|
|
487
|
+
return conn;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
exports.Pool = Pool;
|
|
491
|
+
class Connection {
|
|
492
|
+
constructor(etc, link) {
|
|
493
|
+
this._last = 0;
|
|
494
|
+
this._using = false;
|
|
495
|
+
this._lost = false;
|
|
496
|
+
this._etc = etc;
|
|
497
|
+
this._link = link;
|
|
498
|
+
this.refreshLast();
|
|
499
|
+
}
|
|
500
|
+
getEtc() {
|
|
501
|
+
return this._etc;
|
|
502
|
+
}
|
|
503
|
+
getLast() {
|
|
504
|
+
return this._last;
|
|
505
|
+
}
|
|
506
|
+
setLost() {
|
|
507
|
+
this._lost = true;
|
|
508
|
+
}
|
|
509
|
+
isLost() {
|
|
510
|
+
return this._lost;
|
|
511
|
+
}
|
|
512
|
+
setUsing() {
|
|
513
|
+
this._using = true;
|
|
514
|
+
}
|
|
515
|
+
isUsing() {
|
|
516
|
+
return this._using;
|
|
517
|
+
}
|
|
518
|
+
used() {
|
|
519
|
+
this._using = false;
|
|
520
|
+
}
|
|
521
|
+
refreshLast() {
|
|
522
|
+
this._last = time.stamp();
|
|
523
|
+
}
|
|
524
|
+
async end() {
|
|
525
|
+
try {
|
|
526
|
+
await this._link.close();
|
|
527
|
+
}
|
|
528
|
+
catch {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
async set(key, val, ttl, mod, etc) {
|
|
533
|
+
this.refreshLast();
|
|
534
|
+
if (typeof val !== 'string') {
|
|
535
|
+
val = text.stringifyJson(val);
|
|
536
|
+
}
|
|
537
|
+
try {
|
|
538
|
+
switch (mod) {
|
|
539
|
+
case '': {
|
|
540
|
+
return await this._link.set(etc.pre + key, val, ttl === 0 ? undefined : ttl);
|
|
541
|
+
}
|
|
542
|
+
case 'nx': {
|
|
543
|
+
return await this._link.setNX(etc.pre + key, val, ttl === 0 ? undefined : ttl);
|
|
544
|
+
}
|
|
545
|
+
case 'xx': {
|
|
546
|
+
return await this._link.replace(etc.pre + key, val, ttl === 0 ? undefined : ttl);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
catch {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
async add(key, val, ttl, etc) {
|
|
555
|
+
return this.set(key, val, ttl, 'nx', etc);
|
|
556
|
+
}
|
|
557
|
+
async replace(key, val, ttl, etc) {
|
|
558
|
+
return this.set(key, val, ttl, 'xx', etc);
|
|
559
|
+
}
|
|
560
|
+
async append(key, val, etc) {
|
|
561
|
+
this.refreshLast();
|
|
562
|
+
try {
|
|
563
|
+
return await this._link.append(etc.pre + key, val) > 0 ? true : false;
|
|
564
|
+
}
|
|
565
|
+
catch {
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
async prepend(key, val, etc) {
|
|
570
|
+
this.refreshLast();
|
|
571
|
+
try {
|
|
572
|
+
const script = `local val = redis.call('GET', KEYS[1])
|
|
573
|
+
if (val == false) then
|
|
574
|
+
return 0
|
|
575
|
+
end
|
|
576
|
+
local r = redis.call('SET', KEYS[1], ARGV[1]..val)
|
|
577
|
+
if (r) then
|
|
578
|
+
return 1
|
|
579
|
+
else
|
|
580
|
+
return 0
|
|
581
|
+
end`;
|
|
582
|
+
let r = await this._link.evalSHA('ea360f3f6508a243824ecda6be15db56df217873', [etc.pre + key], [val]);
|
|
583
|
+
r = parseInt(r);
|
|
584
|
+
if (r <= 0) {
|
|
585
|
+
await this._link.scriptLoad(script);
|
|
586
|
+
r = this._link.evalSHA('ea360f3f6508a243824ecda6be15db56df217873', [etc.pre + key], [val]);
|
|
587
|
+
r = parseInt(r);
|
|
588
|
+
}
|
|
589
|
+
return r > 0 ? true : false;
|
|
590
|
+
}
|
|
591
|
+
catch {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
async exists(keys, etc) {
|
|
596
|
+
this.refreshLast();
|
|
597
|
+
try {
|
|
598
|
+
if (typeof keys === 'string') {
|
|
599
|
+
keys = [keys];
|
|
600
|
+
}
|
|
601
|
+
for (let k = 0; k < keys.length; ++k) {
|
|
602
|
+
keys[k] = etc.pre + keys[k];
|
|
603
|
+
}
|
|
604
|
+
return await this._link.mExists(keys);
|
|
605
|
+
}
|
|
606
|
+
catch {
|
|
607
|
+
return 0;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
async get(key, etc) {
|
|
611
|
+
this.refreshLast();
|
|
612
|
+
try {
|
|
613
|
+
return await this._link.get(etc.pre + key);
|
|
614
|
+
}
|
|
615
|
+
catch {
|
|
616
|
+
return null;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
async ttl(key, etc) {
|
|
620
|
+
this.refreshLast();
|
|
621
|
+
try {
|
|
622
|
+
return await this._link.ttl(etc.pre + key);
|
|
623
|
+
}
|
|
624
|
+
catch {
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
async pttl(key, etc) {
|
|
629
|
+
this.refreshLast();
|
|
630
|
+
try {
|
|
631
|
+
return await this._link.pTTL(etc.pre + key);
|
|
632
|
+
}
|
|
633
|
+
catch {
|
|
634
|
+
return null;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
async mGet(keys, etc) {
|
|
638
|
+
this.refreshLast();
|
|
639
|
+
for (let k = 0; k < keys.length; ++k) {
|
|
640
|
+
keys[k] = etc.pre + keys[k];
|
|
641
|
+
}
|
|
642
|
+
const rtn = {};
|
|
643
|
+
try {
|
|
644
|
+
const pl = etc.pre.length;
|
|
645
|
+
const r = await this._link.mGet(keys);
|
|
646
|
+
if (pl === 0) {
|
|
647
|
+
return r;
|
|
648
|
+
}
|
|
649
|
+
for (const k in r) {
|
|
650
|
+
rtn[k.slice(pl)] = r[k];
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
catch {
|
|
654
|
+
for (const key of keys) {
|
|
655
|
+
rtn[key] = null;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return rtn;
|
|
659
|
+
}
|
|
660
|
+
async mSet(rows, etc) {
|
|
661
|
+
this.refreshLast();
|
|
662
|
+
try {
|
|
663
|
+
const rtn = {};
|
|
664
|
+
for (const key in rows) {
|
|
665
|
+
rtn[etc.pre + key] = rows[key];
|
|
666
|
+
}
|
|
667
|
+
await this._link.mSet(rtn);
|
|
668
|
+
return true;
|
|
669
|
+
}
|
|
670
|
+
catch {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
async getJson(key, etc) {
|
|
675
|
+
const v = await this.get(key, etc);
|
|
676
|
+
if (v === null) {
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
const r = text.parseJson(v);
|
|
680
|
+
return r === false ? null : r;
|
|
681
|
+
}
|
|
682
|
+
async del(keys, etc) {
|
|
683
|
+
this.refreshLast();
|
|
684
|
+
if (typeof keys === 'string') {
|
|
685
|
+
keys = [keys];
|
|
686
|
+
}
|
|
687
|
+
for (let k = 0; k < keys.length; ++k) {
|
|
688
|
+
keys[k] = etc.pre + keys[k];
|
|
689
|
+
}
|
|
690
|
+
try {
|
|
691
|
+
return await this._link.del(keys) > 0 ? true : false;
|
|
692
|
+
}
|
|
693
|
+
catch {
|
|
694
|
+
return false;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
async incr(key, num, etc) {
|
|
698
|
+
this.refreshLast();
|
|
699
|
+
try {
|
|
700
|
+
if (Number.isInteger(num)) {
|
|
701
|
+
if (num === 1) {
|
|
702
|
+
return await this._link.incr(etc.pre + key);
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
return await this._link.incr(etc.pre + key, num);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
return await this._link.incrByFloat(etc.pre + key, num);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
catch {
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
async decr(key, num, etc) {
|
|
717
|
+
this.refreshLast();
|
|
718
|
+
try {
|
|
719
|
+
if (Number.isInteger(num)) {
|
|
720
|
+
if (num === 1) {
|
|
721
|
+
return await this._link.decr(etc.pre + key);
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
return await this._link.decr(etc.pre + key, num);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
return await this._link.incrByFloat(etc.pre + key, -num);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
catch {
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
async expire(key, ttl, etc) {
|
|
736
|
+
this.refreshLast();
|
|
737
|
+
try {
|
|
738
|
+
return await this._link.expire(etc.pre + key, ttl);
|
|
739
|
+
}
|
|
740
|
+
catch {
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async keys(pattern, etc) {
|
|
745
|
+
this.refreshLast();
|
|
746
|
+
try {
|
|
747
|
+
const r = await this._link.keys(etc.pre + pattern);
|
|
748
|
+
const pl = etc.pre.length;
|
|
749
|
+
if (pl > 0) {
|
|
750
|
+
for (let k = 0; k < r.length; ++k) {
|
|
751
|
+
r[k] = r[k].slice(pl);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return r;
|
|
755
|
+
}
|
|
756
|
+
catch {
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
async scan(cursor, pattern, count, etc) {
|
|
761
|
+
this.refreshLast();
|
|
762
|
+
try {
|
|
763
|
+
const r = await this._link.scan(cursor, etc.pre + pattern, count);
|
|
764
|
+
for (let i = 0; i < r.items.length; ++i) {
|
|
765
|
+
r.items[i] = r.items[i].slice(this._etc.pre.length);
|
|
766
|
+
}
|
|
767
|
+
return r;
|
|
768
|
+
}
|
|
769
|
+
catch {
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
async flushDb() {
|
|
774
|
+
this.refreshLast();
|
|
775
|
+
try {
|
|
776
|
+
await this._link.flushDb();
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
catch {
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
async ping() {
|
|
784
|
+
this.refreshLast();
|
|
785
|
+
try {
|
|
786
|
+
return (await this._link.ping()) === 'PONG' ? 'PONG' : false;
|
|
787
|
+
}
|
|
788
|
+
catch {
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
async hSet(key, field, val, mod, etc) {
|
|
793
|
+
this.refreshLast();
|
|
794
|
+
try {
|
|
795
|
+
if (typeof val !== 'string') {
|
|
796
|
+
val = text.stringifyJson(val);
|
|
797
|
+
}
|
|
798
|
+
if (mod === 'nx') {
|
|
799
|
+
return await this._link.hSetNX(etc.pre + key, field, val);
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
return await this._link.hSet(etc.pre + key, field, val);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
catch {
|
|
806
|
+
return false;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
async hMSet(key, rows, etc) {
|
|
810
|
+
this.refreshLast();
|
|
811
|
+
try {
|
|
812
|
+
for (const i in rows) {
|
|
813
|
+
const val = rows[i];
|
|
814
|
+
if (typeof val === 'object') {
|
|
815
|
+
rows[i] = text.stringifyJson(val);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
await this._link.hMSet(etc.pre + key, rows);
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
catch {
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
async hGet(key, field, etc) {
|
|
826
|
+
this.refreshLast();
|
|
827
|
+
try {
|
|
828
|
+
return await this._link.hGet(etc.pre + key, field);
|
|
829
|
+
}
|
|
830
|
+
catch {
|
|
831
|
+
return null;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
async hGetJson(key, field, etc) {
|
|
835
|
+
const v = await this.hGet(key, field, etc);
|
|
836
|
+
if (v === null) {
|
|
837
|
+
return null;
|
|
838
|
+
}
|
|
839
|
+
const r = text.parseJson(v);
|
|
840
|
+
return r === false ? null : v;
|
|
841
|
+
}
|
|
842
|
+
async hMGet(key, fields, etc) {
|
|
843
|
+
this.refreshLast();
|
|
844
|
+
try {
|
|
845
|
+
return await this._link.hMGet(etc.pre + key, fields);
|
|
846
|
+
}
|
|
847
|
+
catch {
|
|
848
|
+
const rtn = {};
|
|
849
|
+
for (const field of fields) {
|
|
850
|
+
rtn[field] = null;
|
|
851
|
+
}
|
|
852
|
+
return rtn;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
async hGetAll(key, etc) {
|
|
856
|
+
this.refreshLast();
|
|
857
|
+
try {
|
|
858
|
+
return await this._link.hGetAll(etc.pre + key);
|
|
859
|
+
}
|
|
860
|
+
catch {
|
|
861
|
+
return null;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
async hDel(key, fields, etc) {
|
|
865
|
+
this.refreshLast();
|
|
866
|
+
try {
|
|
867
|
+
return await this._link.hDel(etc.pre + key, fields);
|
|
868
|
+
}
|
|
869
|
+
catch {
|
|
870
|
+
return 0;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
async hExists(key, field, etc) {
|
|
874
|
+
this.refreshLast();
|
|
875
|
+
try {
|
|
876
|
+
return await this._link.hExists(etc.pre + key, field);
|
|
877
|
+
}
|
|
878
|
+
catch {
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
async hIncr(key, field, increment, etc) {
|
|
883
|
+
this.refreshLast();
|
|
884
|
+
try {
|
|
885
|
+
if (Number.isInteger(increment)) {
|
|
886
|
+
return await this._link.hIncr(etc.pre + key, field, increment);
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
return await this._link.hIncrByFloat(etc.pre + key, field, increment);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
catch {
|
|
893
|
+
return 0;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
async hKeys(key, etc) {
|
|
897
|
+
this.refreshLast();
|
|
898
|
+
try {
|
|
899
|
+
return await this._link.hKeys(etc.pre + key);
|
|
900
|
+
}
|
|
901
|
+
catch {
|
|
902
|
+
return [];
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
async lPush(key, values, etc) {
|
|
906
|
+
this.refreshLast();
|
|
907
|
+
try {
|
|
908
|
+
return await this._link.lPush(etc.pre + key, values);
|
|
909
|
+
}
|
|
910
|
+
catch {
|
|
911
|
+
return 0;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
async rPush(key, values, etc) {
|
|
915
|
+
this.refreshLast();
|
|
916
|
+
try {
|
|
917
|
+
return await this._link.rPush(etc.pre + key, values);
|
|
918
|
+
}
|
|
919
|
+
catch {
|
|
920
|
+
return 0;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
async bLMove(sourceKey, destKey, soo, deo, timeout, etc) {
|
|
924
|
+
this.refreshLast();
|
|
925
|
+
try {
|
|
926
|
+
return await this._link.bLMove(etc.pre + sourceKey, etc.pre + destKey, soo, deo, timeout);
|
|
927
|
+
}
|
|
928
|
+
catch {
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
async lPop(key, etc) {
|
|
933
|
+
this.refreshLast();
|
|
934
|
+
try {
|
|
935
|
+
return await this._link.lPop(etc.pre + key);
|
|
936
|
+
}
|
|
937
|
+
catch {
|
|
938
|
+
return null;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
async rPop(key, etc) {
|
|
942
|
+
this.refreshLast();
|
|
943
|
+
try {
|
|
944
|
+
return await this._link.rPop(etc.pre + key);
|
|
945
|
+
}
|
|
946
|
+
catch {
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
async bRPop(key, timeout, etc) {
|
|
951
|
+
this.refreshLast();
|
|
952
|
+
try {
|
|
953
|
+
if (typeof key === 'string') {
|
|
954
|
+
key = [key];
|
|
955
|
+
}
|
|
956
|
+
return await this._link.bRPop(key.map(item => etc.pre + item), timeout);
|
|
957
|
+
}
|
|
958
|
+
catch {
|
|
959
|
+
return {};
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
async lRange(key, start, stop, etc) {
|
|
963
|
+
this.refreshLast();
|
|
964
|
+
try {
|
|
965
|
+
return await this._link.lRange(etc.pre + key, start, stop);
|
|
966
|
+
}
|
|
967
|
+
catch {
|
|
968
|
+
return [];
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
async lLen(key, etc) {
|
|
972
|
+
this.refreshLast();
|
|
973
|
+
try {
|
|
974
|
+
return await this._link.lLen(etc.pre + key);
|
|
975
|
+
}
|
|
976
|
+
catch {
|
|
977
|
+
return 0;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
exports.Connection = Connection;
|
|
982
|
+
function get(ctr, etc) {
|
|
983
|
+
if (!etc) {
|
|
984
|
+
etc = ctr.getPrototype('_config').kv;
|
|
985
|
+
}
|
|
986
|
+
return new Pool(ctr, etc);
|
|
987
|
+
}
|
|
988
|
+
function getConnectionList() {
|
|
989
|
+
const list = [];
|
|
990
|
+
for (let i = 0; i < connections.length; ++i) {
|
|
991
|
+
const connection = connections[i];
|
|
992
|
+
const etc = connection.getEtc();
|
|
993
|
+
list.push({
|
|
994
|
+
'id': i,
|
|
995
|
+
'last': connection.getLast(),
|
|
996
|
+
'host': etc.host,
|
|
997
|
+
'port': etc.port,
|
|
998
|
+
'index': etc.index,
|
|
999
|
+
'lost': connection.isLost(),
|
|
1000
|
+
'using': connection.isUsing()
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
return list;
|
|
1004
|
+
}
|