-
Notifications
You must be signed in to change notification settings - Fork 14
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
Limit inProgress using maxItems #11
Conversation
This looks good to me. But what do you think about making it so that (inProgress + queue.Length < max). I think that maybe a better guarantee to provide. |
while (queue.length && queue[0].time <= now) { | ||
var inProgressSize = Object.keys(inProgress).length; | ||
|
||
while (queue.length && queue[0].time <= now && inProgressSize++ < self.maxItems) { |
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.
why the ++
in inProgressSize++
?
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.
oh it's because the loop adds to the inProgress map - makes sense!
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.
Because we add an item to Well, looks like I don't have real-time comments 😅inProgress
inside of the loop, so the length grows. It's a slightly faster version of
@f2prateek not really sure. To enforce it dynamically (based on the sum of the two queue sizes) you would need to drop new items, while the current behaviour is to drop the oldest item when Using a fixed size for both makes
|
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.
LGTM! Pending CI passes
ccfcd63
to
b894ec4
Compare
Codecov Report
@@ Coverage Diff @@
## master #11 +/- ##
==========================================
- Coverage 94.4% 94.38% -0.03%
==========================================
Files 4 4
Lines 268 267 -1
==========================================
- Hits 253 252 -1
Misses 15 15
Continue to review full report at Codecov.
|
#10 needs to be merged first to fix the tests |
b894ec4
to
fd1419d
Compare
fd1419d
to
78c309d
Compare
@f2prateek rebased, CI now passes 💯 |
Blocked by #10
If the
done
callback is never calledinProgress
can grow infinitely whenaddItem
is called. This PR checks thatinProgress < maxItems
before adding items to it.Ref: https://segment.atlassian.net/browse/LIB-359
cc @f2prateek