From 7fd11b9967f90311c6bfaf9d05aef6b4c5852033 Mon Sep 17 00:00:00 2001 From: ysawada Date: Thu, 11 Jul 2019 17:14:47 +0900 Subject: [PATCH] fix: fix not to use callback to node-resque --- index.js | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index bfefea7..7e2cc63 100644 --- a/index.js +++ b/index.js @@ -86,25 +86,29 @@ class ExecutorQueue extends Executor { }; // Jobs object to register the worker with const jobs = { - startDelayed: Object.assign({ perform: (jobConfig, callback) => - this.redisBreaker.runCommand('hget', this.periodicBuildTable, - jobConfig.jobId) - .then(fullConfig => this.startPeriodic(Object.assign(JSON.parse(fullConfig), - { triggerBuild: true }))) - .then(result => callback(null, result), (err) => { - winston.error('err in startDelayed job: ', err); - callback(err); - }) - }, retryOptions), - startFrozen: Object.assign({ perform: (jobConfig, callback) => - this.redisBreaker.runCommand('hget', this.frozenBuildTable, - jobConfig.jobId) - .then(fullConfig => this.startFrozen(JSON.parse(fullConfig))) - .then(result => callback(null, result), (err) => { - winston.error('err in startFrozen job: ', err); - callback(err); - }) - }, retryOptions) + startDelayed: Object.assign({ perform: async (jobConfig) => { + try { + const fullConfig = await this.redisBreaker + .runCommand('hget', this.periodicBuildTable, jobConfig.jobId); + + return await this.startPeriodic( + Object.assign(JSON.parse(fullConfig), { triggerBuild: true })); + } catch (err) { + winston.error('err in startDelayed job: ', err); + throw err; + } + } }, retryOptions), + startFrozen: Object.assign({ perform: async (jobConfig) => { + try { + const fullConfig = await this.redisBreaker + .runCommand('hget', this.frozenBuildTable, jobConfig.jobId); + + return await this.startFrozen(JSON.parse(fullConfig)); + } catch (err) { + winston.error('err in startFrozen job: ', err); + throw err; + } + } }, retryOptions) }; // eslint-disable-next-line new-cap