jsql-neo 5.2.0 → 5.2.1
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/README.md +29 -1
- package/lib/database.js +20 -1
- package/lib/mongo_server.js +483 -0
- package/lib/multiserver.js +141 -0
- package/lib/mysql_server.js +1 -1
- package/lib/pg_server.js +864 -0
- package/lib/redis_server.js +24 -15
- package/package.json +1 -1
package/lib/redis_server.js
CHANGED
|
@@ -358,25 +358,34 @@ class RedisServer {
|
|
|
358
358
|
|
|
359
359
|
/* ---------- RESP protocol ---------- */
|
|
360
360
|
listen() {
|
|
361
|
-
this.server = net.createServer((socket) =>
|
|
362
|
-
let buf = Buffer.alloc(0);
|
|
363
|
-
this._authedSockets.set(socket, false);
|
|
364
|
-
socket.setEncoding('utf8');
|
|
365
|
-
socket.on('data', (chunk) => {
|
|
366
|
-
buf += chunk;
|
|
367
|
-
for (;;) {
|
|
368
|
-
const msg = this._parse(buf);
|
|
369
|
-
if (!msg) break;
|
|
370
|
-
buf = buf.slice(msg.consumed);
|
|
371
|
-
this._handle(socket, msg.cmd, msg.args);
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
socket.on('error', () => {});
|
|
375
|
-
});
|
|
361
|
+
this.server = net.createServer((socket) => this._handleSocket(socket));
|
|
376
362
|
this.server.listen(this.port, this.host);
|
|
377
363
|
return this;
|
|
378
364
|
}
|
|
379
365
|
|
|
366
|
+
/** 供多协议嗅探复用:把 socket 交给 Redis 处理,可携带已缓冲的首包 */
|
|
367
|
+
_handleSocket(socket, existing = '') {
|
|
368
|
+
let buf = String(existing || '');
|
|
369
|
+
this._authedSockets.set(socket, false);
|
|
370
|
+
socket.setEncoding('utf8');
|
|
371
|
+
socket.on('data', (chunk) => {
|
|
372
|
+
buf += chunk;
|
|
373
|
+
for (;;) {
|
|
374
|
+
const msg = this._parse(buf);
|
|
375
|
+
if (!msg) break;
|
|
376
|
+
buf = buf.slice(msg.consumed);
|
|
377
|
+
this._handle(socket, msg.cmd, msg.args);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
socket.on('error', () => {});
|
|
381
|
+
for (;;) {
|
|
382
|
+
const msg = this._parse(buf);
|
|
383
|
+
if (!msg) break;
|
|
384
|
+
buf = buf.slice(msg.consumed);
|
|
385
|
+
this._handle(socket, msg.cmd, msg.args);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
380
389
|
_parse(buf) {
|
|
381
390
|
if (buf[0] !== '*') {
|
|
382
391
|
const i = buf.indexOf('\r\n');
|