Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added semaphore and blue-test for specific failed test. #71

Closed
wants to merge 2 commits into from

Conversation

helio-frota
Copy link
Member

No description provided.

@ghost ghost assigned helio-frota Jun 13, 2017
@ghost ghost added the in progress label Jun 13, 2017
@helio-frota helio-frota requested a review from lance June 13, 2017 15:03
@coveralls
Copy link

coveralls commented Jun 13, 2017

Coverage Status

Coverage increased (+0.01%) to 99.288% when pulling daeac7e on opossum-60 into fd0fee2 on master.

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty big diff, and it's hard to tell, but it seems the real change is simply wrapping all of the code from fire() within a semaphore.use() scope. Is that the case? Or are there other subtle differences I am missing here?

Also, with regard to the code wrapping, I think it can be narrower in scope. Take a look at my comments below.

Other than these issues, it looks good. Thanks!

*/
this.emit('cacheMiss');
}
const semaphore = new Semaphore(this.options.capacity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a class property. Creating a new semaphore each time the circuit fires doesn't achieve the goal of rate limiting, because the semaphore is only ever used once, and cannot block other code paths from acquiring it.


let timeout;
let timeoutError = false;
return new Promise((resolve, reject) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to call semaphore.use() until here. All of the other stuff should be allowed to execute. E.g. I think it's safe to check for a cache hit and also to check if the circuit is open before attempting to acquire the semaphore. No reason for that stuff to be rate limited.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Will change this. Thanks !

@helio-frota
Copy link
Member Author

helio-frota> I'll close the PR on opossum and see what happened, I saw that the comments are changed, and was not me
<helio-frota> I think I forgot to update before send
<helio-frota> Emitted when the circuit breaker is open and failing fast
<helio-frota> Emitted when the circuit breaker action is executed
<helio-frota> going to close the PR and send again this is not part of my intention

@helio-frota
Copy link
Member Author

real change is simply wrapping all of the code from fire() within a semaphore.use() scope. Is that the case?

Yes.

@ghost ghost removed the in progress label Jun 13, 2017
@helio-frota helio-frota deleted the opossum-60 branch June 13, 2017 16:36
@helio-frota
Copy link
Member Author

Changes and new PR here #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants