Skip to content

Commit 91e5c1d

Browse files
committed
Merge pull request #2 from monolithed/msgpack5
msgpack -> msgpack5
2 parents aaf5261 + 344f786 commit 91e5c1d

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

lib/connection.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var tarantoolConstants = require('./const');
33
var net = require('net');
44
var _ = require('underscore');
55
var EventEmitter = require('events');
6-
var msgpack = require('msgpack');
6+
var msgpack = require('msgpack5')();
77
var vow = require('vow');
88
var crypto = require('crypto');
99
var xor = require('bitwise-xor');
@@ -128,7 +128,8 @@ TarantoolConnection.prototype._responseBufferTrack = function(buffer, length){
128128
TarantoolConnection.prototype._processResponse = function(buffer){
129129
// add fixarraymap with 2 objects before main object
130130
var dataBuffer = Buffer.concat([new Buffer([0x92]), buffer]);
131-
var obj = msgpack.unpack(dataBuffer);
131+
var obj = msgpack.decode(dataBuffer);
132+
132133
var reqId = obj[0][1];
133134
for(var i = 0; i<this.commandsQueue.length; i++)
134135
if (this.commandsQueue[i][1] == reqId)
@@ -205,11 +206,11 @@ TarantoolConnection.prototype.select = function(spaceId, indexId, limit, offset,
205206
if (iterator == 'all')
206207
key = [];
207208
var buffered = {
208-
spaceId: msgpack.pack(spaceId),
209-
indexId: msgpack.pack(indexId),
210-
limit: msgpack.pack(limit),
211-
offset: msgpack.pack(offset),
212-
key: msgpack.pack(key)
209+
spaceId: msgpack.encode(spaceId),
210+
indexId: msgpack.encode(indexId),
211+
limit: msgpack.encode(limit),
212+
offset: msgpack.encode(offset),
213+
key: msgpack.encode(key)
213214
};
214215
var body = Buffer.concat([new Buffer([0x86,tarantoolConstants.KeysCode.space_id]), buffered.spaceId,
215216
new Buffer([tarantoolConstants.KeysCode.index_id]), buffered.indexId,
@@ -229,9 +230,9 @@ TarantoolConnection.prototype.delete = function(spaceId, indexId, key){
229230
var reqId = requestId.getId();
230231
var header = this._header(tarantoolConstants.RequestCode.rqDelete, reqId);
231232
var buffered = {
232-
spaceId: msgpack.pack(spaceId),
233-
indexId: msgpack.pack(indexId),
234-
key: msgpack.pack(key)
233+
spaceId: msgpack.encode(spaceId),
234+
indexId: msgpack.encode(indexId),
235+
key: msgpack.encode(key)
235236
};
236237
var body = Buffer.concat([new Buffer([0x86,tarantoolConstants.KeysCode.space_id]), buffered.spaceId,
237238
new Buffer([tarantoolConstants.KeysCode.index_id]), buffered.indexId,
@@ -247,10 +248,10 @@ TarantoolConnection.prototype.update = function(spaceId, indexId, key, ops){
247248
var reqId = requestId.getId();
248249
var header = this._header(tarantoolConstants.RequestCode.rqUpdate, reqId);
249250
var buffered = {
250-
spaceId: msgpack.pack(spaceId),
251-
indexId: msgpack.pack(indexId),
252-
ops: msgpack.pack(ops),
253-
key: msgpack.pack(key)
251+
spaceId: msgpack.encode(spaceId),
252+
indexId: msgpack.encode(indexId),
253+
ops: msgpack.encode(ops),
254+
key: msgpack.encode(key)
254255
};
255256
var body = Buffer.concat([new Buffer([0x84,tarantoolConstants.KeysCode.space_id]), buffered.spaceId,
256257
new Buffer([tarantoolConstants.KeysCode.index_id]), buffered.indexId,
@@ -269,8 +270,8 @@ TarantoolConnection.prototype.eval = function(expression, tuple){
269270
var reqId = requestId.getId();
270271
var header = this._header(tarantoolConstants.RequestCode.rqEval, reqId);
271272
var buffered = {
272-
expression: msgpack.pack(expression),
273-
tuple: msgpack.pack(tuple)
273+
expression: msgpack.encode(expression),
274+
tuple: msgpack.encode(tuple)
274275
};
275276
var body = Buffer.concat([new Buffer([0x82,tarantoolConstants.KeysCode.expression]), buffered.expression,
276277
new Buffer([tarantoolConstants.KeysCode.tuple]), buffered.tuple]);
@@ -284,8 +285,8 @@ TarantoolConnection.prototype.call = function(functionName, tuple){
284285
var reqId = requestId.getId();
285286
var header = this._header(tarantoolConstants.RequestCode.rqCall, reqId);
286287
var buffered = {
287-
functionName: msgpack.pack(functionName),
288-
tuple: msgpack.pack(tuple)
288+
functionName: msgpack.encode(functionName),
289+
tuple: msgpack.encode(tuple)
289290
};
290291
var body = Buffer.concat([new Buffer([0x82,tarantoolConstants.KeysCode.function_name]), buffered.functionName,
291292
new Buffer([tarantoolConstants.KeysCode.tuple]), buffered.tuple]);
@@ -309,8 +310,8 @@ TarantoolConnection.prototype._replaceInsert = function(cmd, reqId, spaceId, tup
309310
if (Array.isArray(tuple)){
310311
var header = this._header(cmd, reqId);
311312
var buffered = {
312-
spaceId: msgpack.pack(spaceId),
313-
tuple: msgpack.pack(tuple)
313+
spaceId: msgpack.encode(spaceId),
314+
tuple: msgpack.encode(tuple)
314315
};
315316
var body = Buffer.concat([new Buffer([0x82,tarantoolConstants.KeysCode.space_id]), buffered.spaceId,
316317
new Buffer([tarantoolConstants.KeysCode.tuple]), buffered.tuple]);
@@ -327,7 +328,7 @@ TarantoolConnection.prototype.auth = function(username, password){
327328
var reqId = requestId.getId();
328329
var header = this._header(tarantoolConstants.RequestCode.rqAuth, reqId);
329330
var buffered = {
330-
username: msgpack.pack(username)
331+
username: msgpack.encode(username)
331332
};
332333
var scrambled = scramble(password, this.salt);
333334
var body = Buffer.concat([new Buffer([0x82, tarantoolConstants.KeysCode.username]), buffered.username,

lib/const.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var msgpack = require('msgpack');
1+
var msgpack = require('msgpack5')();
2+
23
// i steal it from go
34
const RequestCode = {
45
rqConnect: 0x00, //fake for connect
@@ -57,7 +58,7 @@ const ExportPackage = {
5758
KeysCode: KeysCode,
5859
IteratorsType: IteratorsType,
5960
OkCode: OkCode,
60-
passEnter: msgpack.pack('chap-sha1')
61+
passEnter: msgpack.encode('chap-sha1')
6162
};
6263

6364
module.exports = ExportPackage;

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tarantool-driver",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Tarantool driver for 1.6",
55
"main": "index.js",
66
"scripts": {
@@ -14,7 +14,7 @@
1414
"tarantool",
1515
"driver",
1616
"db",
17-
"msgpack"
17+
"msgpack"
1818
],
1919
"author": "KlonD90",
2020
"license": "MIT",
@@ -24,7 +24,7 @@
2424
"homepage": "https://github.com/KlonD90/node-tarantool-driver",
2525
"dependencies": {
2626
"bitwise-xor": "0.0.0",
27-
"msgpack": "^0.2.6",
27+
"msgpack5": "^3.0.0",
2828
"underscore": "^1.8.3",
2929
"vow": "^0.4.9"
3030
},

0 commit comments

Comments
 (0)