Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
ngot committed Mar 28, 2018
1 parent e0a7a77 commit 1ee4785
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const is = require('is-type-of');
const crypto = require('crypto');
const Base = require('tcp-base');
const promisify = require('util').promisify;
const RemotingCommand = require('./protocol/command/remoting_command');

class Channel extends Base {
Expand All @@ -24,6 +25,7 @@ class Channel extends Base {
headerLength: 4,
needHeartbeat: false,
}, options));
this.sendPromise = promisify(this.send);
}

get accessKey() {
Expand Down Expand Up @@ -98,9 +100,9 @@ class Channel extends Base {
* @param {Number} timeout - response timeout
* @return {Object} response
*/
async invoke(command, timeout) {
invoke(command, timeout) {
this.beforeRequest(command);
return await this.sendThunk({
return this.sendPromise({
id: command.opaque,
data: command.encode(),
timeout,
Expand All @@ -110,11 +112,11 @@ class Channel extends Base {
/**
* invoke rocketmq api without need response
* @param {RemotingCommand} command - remoting command
* @return {void}
* @return {Promise} Promise
*/
async invokeOneway(command) {
invokeOneway(command) {
this.beforeRequest(command);
await this.sendThunk({
return this.sendPromise({
id: command.opaque,
data: command.encode(),
oneway: true,
Expand Down

0 comments on commit 1ee4785

Please sign in to comment.