Skip to content

Commit

Permalink
fix: remove breaker (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
d2lam committed Mar 18, 2019
1 parent d7897f9 commit 8fc85fe
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ class ExecutorQueue extends Executor {
this.redisBreaker = new Breaker((funcName, ...args) =>
// Use the queue's built-in connection to send redis commands instead of instantiating a new one
this.redis[funcName](...args), breaker);
this.requestBreaker = new Breaker(requestretry, config.breaker);
this.requestRetryStrategy = (err, response) =>
err || (response.statusCode !== 201 && response.statusCode !== 200);
!!err || (response.statusCode !== 201 && response.statusCode !== 200);

this.fuseBox = new FuseBox();
this.fuseBox.addFuse(this.queueBreaker);
Expand Down Expand Up @@ -212,14 +211,19 @@ class ExecutorQueue extends Executor {
options.body.parentEventId = eventId;
}

return this.requestBreaker.runCommand(options)
.then((response) => {
return new Promise((resolve, reject) => {
requestretry(options, (err, response) => {
if (!err && response.statusCode === 201) {
return resolve(response);
}

if (response.statusCode !== 201) {
throw new Error(JSON.stringify(response.body));
return reject(JSON.stringify(response.body));
}

return null;
return reject(err);
});
});
}

async updateBuildStatus({ buildId, status, statusMessage, token, apiUri }) {
Expand All @@ -240,14 +244,19 @@ class ExecutorQueue extends Executor {
retryStrategy: this.requestRetryStrategy
};

return this.requestBreaker.runCommand(options)
.then((response) => {
return new Promise((resolve, reject) => {
requestretry(options, (err, response) => {
if (!err && response.statusCode === 200) {
return resolve(response);
}

if (response.statusCode !== 200) {
throw new Error(JSON.stringify(response.body));
return reject(JSON.stringify(response.body));
}

return null;
return reject(err);
});
});
}

/**
Expand Down

0 comments on commit 8fc85fe

Please sign in to comment.