Skip to content

1070 Add discard config for rate-limiter - #1096

Merged
manast merged 2 commits into
OptimalBits:masterfrom
wishabi:1070
Oct 24, 2018
Merged

manast merged 2 commits into
OptimalBits:masterfrom
wishabi:1070

Conversation

@aleccool213

@aleccool213 aleccool213 commented Oct 22, 2018 •

Copy link
Copy Markdown
Contributor

- Meant for Manually Fetching Jobs pattern
Comment thread test/test_rate_limiter.js
});

it('should put a job into the delayed queue when limit is hit', function() {
queue.on('failed', function(e) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Might be better to create a new queue here as you did in the test below, since this test assumes that the queue max is set to 1.

Comment thread test/test_rate_limiter.js
})
).then(function() {
return newQueue.getDelayedCount().then(function(delayedCount) {
expect(delayedCount).to.eq(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should also do an assert on the main queue to make sure 3 objects are there. Might also want to assert the ordering of the jobs to make sure that is untouched?

Comment thread lib/commands/moveToActive-8.lua Outdated
local discard = ARGV[8]
jobCounter = tonumber(rcall("GET", KEYS[6]))
if jobCounter ~= nil and jobCounter >= maxJobs then
if discard == 'true' then

@csingh csingh Oct 23, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are there any tests for these .lua scripts? If so, we should update them for this case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there are not test only for the .lua scripts, but integration tests that indirectly call this .lua scripts.

Comment thread PATTERNS.md Outdated

Patterns
========
# Patterns

@csingh csingh Oct 23, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we need all these formatting changes in this PR? :) I would remove if unnecessary, its cluttering things up and distracting from the feature-related changes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there are great changes though, would be nice to have them in a different PR, but if to cumbersome we could accept it in this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will make another pr

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread REFERENCE.md Outdated
duration: number, // per duration in milliseconds
max: number; // Max number of jobs processed
duration: number; // per duration in milliseconds
discard: boolean = false; // When jobs get rate limited, nothing happens

@csingh csingh Oct 23, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

discard might not be the best name for this.. because we're not entirely discarding the rate limiter, we are just disabling the delayed queue. So maybe disableDelyedQueue or something similar? And then change the comment to say something more explicit like When set to true and jobs get rate limited, they stay in the main queue and are not moved to the delayed queue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok, now I full understand the use-case and discard may indeed not be the best name. I thought the idea was to really throw away the jobs that get "throttled". so this name will be misleading. On the other hand, a name like disableDelayedQeuue is a bit techie and exposes implementation details.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure about this name but what about this alternative bounceBack ? the option is quite special since it only has use in the manual processing pattern...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like bounceBack 👍

Comment thread PATTERNS.md Outdated

Patterns
========
# Patterns

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there are great changes though, would be nice to have them in a different PR, but if to cumbersome we could accept it in this one.

Comment thread lib/commands/moveToActive-8.lua Outdated
local discard = ARGV[8]
jobCounter = tonumber(rcall("GET", KEYS[6]))
if jobCounter ~= nil and jobCounter >= maxJobs then
if discard == 'true' then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there are not test only for the .lua scripts, but integration tests that indirectly call this .lua scripts.

Comment thread test/test_rate_limiter.js Outdated
assert.fail(e);
});

return Promise.all(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe it is just better to write this just as:
Promise.all([queue.add({}), queue.add({}), queue.add({}), queue.add({})])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍

Comment thread REFERENCE.md Outdated
duration: number, // per duration in milliseconds
max: number; // Max number of jobs processed
duration: number; // per duration in milliseconds
discard: boolean = false; // When jobs get rate limited, nothing happens

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok, now I full understand the use-case and discard may indeed not be the best name. I thought the idea was to really throw away the jobs that get "throttled". so this name will be misleading. On the other hand, a name like disableDelayedQeuue is a bit techie and exposes implementation details.

Comment thread REFERENCE.md Outdated
duration: number, // per duration in milliseconds
max: number; // Max number of jobs processed
duration: number; // per duration in milliseconds
discard: boolean = false; // When jobs get rate limited, nothing happens

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure about this name but what about this alternative bounceBack ? the option is quite special since it only has use in the manual processing pattern...

@aleccool213

Copy link
Copy Markdown
Contributor Author

@manast new review is up 👍

@manast
manast merged commit 118dba7 into OptimalBits:master Oct 24, 2018
@aleccool213
aleccool213 deleted the 1070 branch October 26, 2018 14:02
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