-
Notifications
You must be signed in to change notification settings - Fork 34
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
Throttling on arbitrary resources. #46
Closed
Closed
Changes from all commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
a3728f0
simple throttle for qless
44df91c
finished renaming resources to throttle
14d0fe3
throttle tests wip
674353a
test fixes
32c795c
wip
4de319b
general working
493d157
throttle api
f6b9a38
throttle changes
36fd0fb
Add Throttle locks and pending member functions
3599db3
wip
9f3bdb9
wip
623ebd9
Fix tests
b21e519
Switch to sorted set
69bd3e7
Fix throttle locks and pending member functions
d3fe766
lock fixes
1e003e5
finished basic tests
4df4123
switched to rank instead of score
7fff784
Acquire throttle on pop
fe776ef
test fixes
4fc8e3c
test fixes
27aebd4
Add tests for dependent throttling
a3244fe
Use throttles to handle max-queue-concurrency
81e2103
removed commented code
b4e7765
support multiple resources
308a77e
implemented multiple throttles per job
5d86598
documentation
5141cbf
Add job tests for multiple throttles
a27ac2e
implemeted queue throttled
d230b54
Merge branch 'throttle' of github.com:backupify/qless-core into throttle
b159933
small changes
6522fe7
Add tests for dynamically changing throttle concurrency level
eaf6be1
Add tests to verify queue throttled
32a1408
Minor optimizations and test fixes
a70362b
Add test for queue throttled count
fc332c9
Add api methods for setting queue throttle max
b54298f
throttles refactor/cleanup
71ac5e0
Update queue.lua
aadd902
fixed syntax error
9595d5e
Simplify job#acquire_throttles
769d4f3
Remove commented code
f7a3b6f
misc fixes
730c668
Merge branch 'throttle' of github.com:backupify/qless-core into throttle
7d85dc8
attempt to throttle jobs immediately
2d9810c
added optional expiration to a throttle
4728f1d
removed printlines
85350ea
Add API to retrieve throttle ttl
5668c32
Set queue throttle expiration to 0
0d8290e
Update test_job.py
9a37225
Merge pull request #1 from backupify/throttle
70a2779
Catch when job has no throttles
dd2d931
test exposing cancel bug
wr0ngway 8f004dc
fix for cancelled
a9c3b98
wip
d1b52be
Merge pull request #2 from backupify/fix_cancel
d7372ab
removed printline statements
f1bf59f
removed debugging code
3b80d6c
Merge pull request #3 from backupify/throttle
3108245
fixes throttle release to properly remove a job from the throttled set
d058374
small optimization
ee6f039
test name change
42aa9be
whitespace fix
3bffc21
Merge pull request #4 from backupify/cancel-fix
d9903a5
fix tags work
56df3fc
test fix
bd089c0
removed unnecessary code
ed4a0f8
removed unnecessary change
9a766e6
Merge pull request #5 from backupify/fix-tags
3550b9b
patches remove_tag method to be more reliable
d821344
Merge pull request #6 from backupify/patch-remove-tags
66c1ebd
Merge branch 'upstream-master' into merge-upstream
3fe1fcd
merged master
6451b7c
Merge remote-tracking branch 'upstream/master' into merge-upstream
65dac2d
Merge pull request #7 from backupify/merge-upstream
james-lawrence cda5ed8
Update throttle.lua
james-lawrence b6fd1aa
test fixes
38e2493
Merge branch 'upstream' into merge-upstream
5dbc192
Merge pull request #8 from backupify/merge-upstream
james-lawrence 21097aa
Merge branch 'upstream-master'
7932ac9
Merge branch 'master' of github.com:backupify/qless-core
8fda126
retry pop up to config limit when pop quantity would be unfulfilled d…
wr0ngway 98b71d6
short circuit retry if nothing in work queue
wr0ngway 4718824
verify contents of waiting jids in tests for max-pop-retry
wr0ngway 8baa512
Merge pull request #9 from backupify/pop_retry
9e5e716
Update api.lua
james-lawrence e8ed50c
Update test_throttle.py
james-lawrence 230a777
tests
e3fdb7e
Merge pull request #10 from backupify/throttle-release-job-api
james-lawrence 6dbf028
Ignore ghost jids that have no real job
20dc687
Remove old queue throttle from reput job
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,7 +135,7 @@ QlessAPI.unpause = function(now, ...) | |
end | ||
|
||
QlessAPI.cancel = function(now, ...) | ||
return Qless.cancel(unpack(arg)) | ||
return Qless.cancel(now, unpack(arg)) | ||
end | ||
|
||
QlessAPI.timeout = function(now, ...) | ||
|
@@ -199,6 +199,55 @@ QlessAPI['queue.forget'] = function(now, ...) | |
QlessQueue.deregister(unpack(arg)) | ||
end | ||
|
||
QlessAPI['queue.throttle.get'] = function(now, queue) | ||
local data = Qless.throttle(QlessQueue.ns .. queue):data() | ||
if not data then | ||
return nil | ||
end | ||
return cjson.encode(data) | ||
end | ||
|
||
QlessAPI['queue.throttle.set'] = function(now, queue, max) | ||
Qless.throttle(QlessQueue.ns .. queue):set({maximum = max}, 0) | ||
end | ||
|
||
-- Throttle apis | ||
QlessAPI['throttle.set'] = function(now, tid, max, ...) | ||
local expiration = unpack(arg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why deal with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was to make it an optional argument, not terrible strong in lua. |
||
local data = { | ||
maximum = max | ||
} | ||
Qless.throttle(tid):set(data, tonumber(expiration or 0)) | ||
end | ||
|
||
QlessAPI['throttle.get'] = function(now, tid) | ||
return cjson.encode(Qless.throttle(tid):data()) | ||
end | ||
|
||
QlessAPI['throttle.delete'] = function(now, tid) | ||
return Qless.throttle(tid):unset() | ||
end | ||
|
||
QlessAPI['throttle.locks'] = function(now, tid) | ||
return Qless.throttle(tid).locks.members() | ||
end | ||
|
||
QlessAPI['throttle.pending'] = function(now, tid) | ||
return Qless.throttle(tid).pending.members() | ||
end | ||
|
||
QlessAPI['throttle.ttl'] = function(now, tid) | ||
return Qless.throttle(tid):ttl() | ||
end | ||
|
||
-- releases the set of jids from the specified throttle. | ||
QlessAPI['throttle.release'] = function(now, tid, ...) | ||
local throttle = Qless.throttle(tid) | ||
|
||
for _, jid in ipairs(arg) do | ||
throttle:release(now, jid) | ||
end | ||
end | ||
------------------------------------------------------------------------------- | ||
-- Function lookup | ||
------------------------------------------------------------------------------- | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 are there separate
queue.throttle.*
APIs when there are alreadythrottle.*
APIs? As far as I can tell, they aren't used by your qless gem PR...Anyhow, if we do still need them for some reason, I'd expect them to be implemented in terms of the
throttle.*
APIs.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.
hold over from an original implementation. unnecessary =)