Skip to content

Commit

Permalink
chore: upgrade deps (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
gxcsoccer authored and denghongcai committed Apr 1, 2019
1 parent 073058b commit a44d4d0
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 39 deletions.
4 changes: 2 additions & 2 deletions lib/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Channel extends Base {
* - {String} accessKey
* - {String} secretKey
* - {String} onsChannel
* @constructor
* @class
*/
constructor(address, options = {}) {
// 10.18.214.201:8080
Expand Down Expand Up @@ -85,7 +85,7 @@ class Channel extends Base {
val += map.get(key);
}
}
let total = new Buffer(val, 'utf8');
let total = Buffer.from(val, 'utf8');
const bodyLength = command.body ? command.body.length : 0;
if (bodyLength) {
total = Buffer.concat([ total, command.body ], total.length + bodyLength);
Expand Down
1 change: 0 additions & 1 deletion lib/consumer/rebalance/allocate_message_queue_strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class AllocateMessageQueueStrategy {
* @param {String} currentCID - 当前 ConsumerId
* @param {Array} mqAll - 当前 Topic 的所有队列集合,无重复数据,且有序
* @param {Array} cidAll - 当前订阅组的所有 Consumer 集合,无重复数据,且有序
* @return {Array} 分配结果
*/
allocate(consumerGroup, currentCID, mqAll, cidAll) { /* eslint no-unused-vars: 0 */
throw new Error('no implementation');
Expand Down
4 changes: 2 additions & 2 deletions lib/message/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Message {
* @param {String} topic -
* @param {String} tags -
* @param {String|Buffer} body -
* @constructor
* @class
*/
constructor(topic, tags, body) {
if (arguments.length === 2) {
Expand All @@ -37,7 +37,7 @@ class Message {
this.tags = tags;

if (body && is.string(body)) {
this.body = new Buffer(body);
this.body = Buffer.from(body);
} else {
this.body = body;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/message/message_decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function innerDecode(byteBuffer, readBody, deCompressBody) {
// 9 BORNTIMESTAMP
msgExt.bornTimestamp = byteBuffer.getLong().toNumber();
// 10 BORNHOST
const host = new Buffer(4);
const host = Buffer.alloc(4);
byteBuffer.get(host);
let port = byteBuffer.getInt();
msgExt.bornHost = host[0] + '.' + host[1] + '.' + host[2] + '.' + host[3] + ':' + port;
Expand All @@ -123,7 +123,7 @@ function innerDecode(byteBuffer, readBody, deCompressBody) {
const bodyLen = byteBuffer.getInt();
if (bodyLen > 0) {
if (readBody) {
let body = new Buffer(bodyLen);
let body = Buffer.alloc(bodyLen);
byteBuffer.get(body);

// uncompress body
Expand All @@ -138,14 +138,14 @@ function innerDecode(byteBuffer, readBody, deCompressBody) {

// 16 TOPIC
const topicLen = byteBuffer.get();
const topic = new Buffer(topicLen);
const topic = Buffer.alloc(topicLen);
byteBuffer.get(topic);
msgExt.topic = topic.toString();

// 17 properties
const propertiesLength = byteBuffer.getShort();
if (propertiesLength > 0) {
const properties = new Buffer(propertiesLength);
const properties = Buffer.alloc(propertiesLength);
byteBuffer.get(properties);
const propertiesString = properties.toString();
msgExt.properties = string2messageProperties(propertiesString);
Expand Down Expand Up @@ -182,7 +182,7 @@ function string2bytes(hexString) {
if (!hexString) {
return null;
}
return new Buffer(hexString, 'hex');
return Buffer.from(hexString, 'hex');
}

function bytes2string(src) {
Expand Down
2 changes: 1 addition & 1 deletion lib/mq_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MQClient extends MQClientAPI {
/**
* metaq client
* @param {Object} clientConfig -
* @constructor
* @class
*/
constructor(clientConfig) {
super(clientConfig.options);
Expand Down
4 changes: 2 additions & 2 deletions lib/mq_client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MQClientAPI extends RemotingClient {
* - {HttpClient} httpclient - http request client
* - {Object} [logger] - log module
* - {Number} [responseTimeout] - tcp response timeout
* @constructor
* @class
*/
constructor(options) {
super(options);
Expand Down Expand Up @@ -219,7 +219,7 @@ class MQClientAPI extends RemotingClient {
}
}
const request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
request.body = new Buffer(JSON.stringify(heartbeatData));
request.body = Buffer.from(JSON.stringify(heartbeatData));
const response = await this.invoke(addr, request, timeout);
if (response.code !== ResponseCode.SUCCESS) {
this._defaultHandler(request, response);
Expand Down
2 changes: 1 addition & 1 deletion lib/producer/mq_producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MQProducer extends ClientConfig {
/**
* metaq message producer
* @param {Object} options -
* @constructor
* @class
*/
constructor(options) {
super(Object.assign({ initMethod: 'init' }, defaultOptions, options));
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/command/remoting_command.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class RemotingCommand {

buildHeader() {
this.makeCustomHeaderToNet();
return new Buffer(JSON.stringify({
return Buffer.from(JSON.stringify({
code: this.code,
language: this.language,
opaque: this.opaque,
Expand Down
2 changes: 1 addition & 1 deletion lib/remoting_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RemotingClient extends Base {
* - {HttpClient} httpclient - http request client
* - {Object} [logger] - log module
* - {Number} [responseTimeout] - tcp response timeout
* @constructor
* @class
*/
constructor(options) {
assert(options.onsAddr || options.nameSrv, '[RemotingClient] options.onsAddr or options.nameSrv one of them is required');
Expand Down
3 changes: 1 addition & 2 deletions lib/store/local_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LocalFileOffsetStore extends Base {
* 消费进度存储到Consumer本地
* @param {MQClient} mqClient -
* @param {String} groupName 分组名
* @contructor
* @class
*/
constructor(mqClient, groupName) {
super();
Expand Down Expand Up @@ -74,7 +74,6 @@ class LocalFileOffsetStore extends Base {
* 从本地缓存读取消费进度
* @param {MessageQueue} messageQueue -
* @param {String} type 消费类型(从哪里开始消费)
* @param {Function} callback 回调函数
* @return {void}
*/
async readOffset(messageQueue, type) {
Expand Down
3 changes: 1 addition & 2 deletions lib/store/local_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LocalMemoryOffsetStore extends Base {
* 消费进度存储到Consumer本地
* @param {MQClient} mqClient -
* @param {String} groupName 分组名
* @contructor
* @class
*/
constructor(mqClient, groupName) {
super();
Expand Down Expand Up @@ -50,7 +50,6 @@ class LocalMemoryOffsetStore extends Base {
* 从本地缓存读取消费进度
* @param {MessageQueue} messageQueue -
* @param {String} type 消费类型(从哪里开始消费)
* @param {Function} callback 回调函数
* @return {void}
*/
async readOffset(messageQueue, type) {
Expand Down
2 changes: 1 addition & 1 deletion lib/store/remote_broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class RemoteBrokerOffsetStore extends Base {
* consume offset store at remote server
* @param {MQClient} mqClient - mq client
* @param {String} groupName - group name
* @constructor
* @class
*/
constructor(mqClient, groupName) {
super();
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"address": "^1.0.3",
"binary-search-insert": "^1.0.3",
"byte": "^2.0.0",
"bytes": "^3.0.0",
"chalk": "^2.4.1",
"debug": "^4.1.0",
"egg-logger": "^2.0.3",
"bytes": "^3.1.0",
"chalk": "^2.4.2",
"debug": "^4.1.1",
"egg-logger": "^2.4.1",
"is-type-of": "^1.2.1",
"long": "^4.0.0",
"mkdirp": "^0.5.1",
Expand All @@ -48,16 +48,16 @@
"p-gather": "^1.0.2",
"sdk-base": "^3.5.1",
"tcp-base": "^3.1.0",
"utility": "^1.15.0"
"utility": "^1.16.1"
},
"devDependencies": {
"autod": "^3.0.1",
"autod": "^3.1.0",
"contributors": "^0.5.1",
"egg-bin": "^4.9.0",
"eslint": "^5.9.0",
"eslint-config-egg": "^7.1.0",
"mm": "^2.4.1",
"urllib": "^2.31.2"
"egg-bin": "^4.12.1",
"eslint": "^5.15.3",
"eslint-config-egg": "^7.3.1",
"mm": "^2.5.0",
"urllib": "^2.33.2"
},
"engines": {
"node": ">= 8.0.0"
Expand Down
6 changes: 3 additions & 3 deletions test/message/message_decoder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('test/message/message_decoder.test.js', function() {
const message = MessageDecoder.decode(buf);
assert(message);
assert(message.msgId === '0ADA91A6000029CC0000006500E59F3E');
assert.deepEqual(message.body, new Buffer('{"room":"1","msg":"1"}'));
assert.deepEqual(message.body, Buffer.from('{"room":"1","msg":"1"}'));
assert(message.tags === 'TagA');
assert(!message.keys);
assert(message.delayTimeLevel === 0);
Expand All @@ -30,7 +30,7 @@ describe('test/message/message_decoder.test.js', function() {
const message = MessageDecoder.decode(buf);
assert(message);
assert(message.msgId === '0ADA91A6000029CC000000661A586D98');
assert.deepEqual(message.body, new Buffer('Hello MetaQ !!!'));
assert.deepEqual(message.body, Buffer.from('Hello MetaQ !!!'));
assert(message.tags, 'TagA');
assert(!message.keys);
assert(message.delayTimeLevel === 0);
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('test/message/message_decoder.test.js', function() {
const messages = MessageDecoder.decodes(buf);
assert(messages.length === 3);
assert(messages[0].msgId === '0ADA91A6000029CC000000659560A2AA');
assert.deepEqual(messages[0].body, new Buffer('Hello MetaQ !!!'));
assert.deepEqual(messages[0].body, Buffer.from('Hello MetaQ !!!'));
assert(messages[1].msgId === '0ADA91A6000029CC000000659560D349');
assert(messages[2].msgId === '0ADA91A6000029CC000000659560D578');
});
Expand Down
8 changes: 4 additions & 4 deletions test/protocol/command/remoting_command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ describe('test/protocol/command/remoting_command.test.js', function() {
key: '192.168.1.103',
});
request.opaque = 1;
assert.deepEqual(request.encode(), new Buffer('00000084000000807b22636f6465223a3231372c226c616e6775616765223a224a415641222c226f7061717565223a312c22666c6167223a302c2276657273696f6e223a37382c226578744669656c6473223a7b226e616d657370616365223a2250524f4a4543545f434f4e464947222c226b6579223a223139322e3136382e312e313033227d7d', 'hex'));
assert.deepEqual(request.encode(), Buffer.from('00000084000000807b22636f6465223a3231372c226c616e6775616765223a224a415641222c226f7061717565223a312c22666c6167223a302c2276657273696f6e223a37382c226578744669656c6473223a7b226e616d657370616365223a2250524f4a4543545f434f4e464947222c226b6579223a223139322e3136382e312e313033227d7d', 'hex'));
const response = RemotingCommand.createResponseCommand(ResponseCode.SUCCESS, 1);
assert.deepEqual(response.encode(), new Buffer('00000075000000717b22636f6465223a302c226c616e6775616765223a224a415641222c226f7061717565223a312c22666c6167223a312c2276657273696f6e223a37382c2272656d61726b223a226e6f742073657420616e7920726573706f6e736520636f6465222c226578744669656c6473223a7b7d7d', 'hex'));
assert.deepEqual(response.encode(), Buffer.from('00000075000000717b22636f6465223a302c226c616e6775616765223a224a415641222c226f7061717565223a312c22666c6167223a312c2276657273696f6e223a37382c2272656d61726b223a226e6f742073657420616e7920726573706f6e736520636f6465222c226578744669656c6473223a7b7d7d', 'hex'));
});

it('should decode command ok', function() {
const request = RemotingCommand.decode(new Buffer('00000084000000807b22636f6465223a3231372c226c616e6775616765223a224a415641222c226f7061717565223a312c22666c6167223a302c2276657273696f6e223a37382c226578744669656c6473223a7b226e616d657370616365223a2250524f4a4543545f434f4e464947222c226b6579223a223139322e3136382e312e313033227d7d', 'hex'));
const request = RemotingCommand.decode(Buffer.from('00000084000000807b22636f6465223a3231372c226c616e6775616765223a224a415641222c226f7061717565223a312c22666c6167223a302c2276657273696f6e223a37382c226578744669656c6473223a7b226e616d657370616365223a2250524f4a4543545f434f4e464947222c226b6579223a223139322e3136382e312e313033227d7d', 'hex'));
assert(request.opaque === 1);
assert(request.code === RequestCode.GET_KV_CONFIG_BY_VALUE);
assert.deepEqual(request.extFields, {
namespace: 'PROJECT_CONFIG',
key: '192.168.1.103',
});
const response = RemotingCommand.decode(new Buffer('00000066000000627b22636f6465223a302c226c616e6775616765223a224a415641222c226f7061717565223a312c22666c6167223a312c2276657273696f6e223a37382c2272656d61726b223a226e6f742073657420616e7920726573706f6e736520636f6465227d', 'hex'));
const response = RemotingCommand.decode(Buffer.from('00000066000000627b22636f6465223a302c226c616e6775616765223a224a415641222c226f7061717565223a312c22666c6167223a312c2276657273696f6e223a37382c2272656d61726b223a226e6f742073657420616e7920726573706f6e736520636f6465227d', 'hex'));
assert(response.opaque === 1);
assert(response.code === ResponseCode.SUCCESS);
assert(response.remark === 'not set any response code');
Expand Down

0 comments on commit a44d4d0

Please sign in to comment.