Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
ngot committed Mar 27, 2018
1 parent 1de2b1a commit 519e164
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/mq_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ module.exports = MQClient;

// Helper
// -----------------
function sleep(interval) {
return callback => setTimeout(callback, interval);
function sleep(n) {
return new Promise(resolve => {
setTimeout(resolve, n);
});
}
8 changes: 4 additions & 4 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('test/index.test.js', () => {
}, config));
await consumer.ready();

consumer.subscribe('TEST_TOPIC', function* (msg) {
consumer.subscribe('TEST_TOPIC', async msg => {
console.log('message receive ------------> ', msg.body.toString());
});
});
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('test/index.test.js', () => {
let sendResult = await producer.send(msg);
assert(sendResult && sendResult.msgId);

mm(producer, 'sendKernelImpl', function* () {
mm(producer, 'sendKernelImpl', async () => {
mm.restore();
const err = new Error('mock err');
err.name = 'MQClientException';
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('test/index.test.js', () => {
});
assert(offset === -1);

mm(consumer._offsetStore, 'readOffset', function* () {
mm(consumer._offsetStore, 'readOffset', async () => {
return 100;
});
offset = await consumer.computePullFromWhere({
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('test/index.test.js', () => {

it('should subscribe message ok', async () => {
let msgId;
consumer.subscribe('TEST_TOPIC', 'TagA', function* (msg) {
consumer.subscribe('TEST_TOPIC', 'TagA', async msg => {
console.log('message receive ------------> ', msg.body.toString());
assert(msg.tags !== 'TagB');
if (msg.msgId === msgId) {
Expand Down

0 comments on commit 519e164

Please sign in to comment.