-
Notifications
You must be signed in to change notification settings - Fork 108
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
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 !
|
Yes. |
Changes and new PR here #72 |
No description provided.