Skip to content

Commit

Permalink
Merge pull request #67 from sonic-screwdriver-cd/fix-for-node-resque
Browse files Browse the repository at this point in the history
fix: fix not to use callback to node-resque
  • Loading branch information
catto authored Jul 11, 2019
2 parents 0d5e6a6 + 7fd11b9 commit 4a4104c
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a4104c

Please sign in to comment.