resque-rate_limited_queue 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +1 -2
- data/lib/resque/plugins/rate_limited_queue/rate_limited_queue.rb +3 -1
- data/lib/resque-rate_limited_queue/version.rb +1 -1
- data/spec/rate_limited_queue_spec.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3d514482bdda5f90ef98a9d898bfe9cc2bd3a4c
|
4
|
+
data.tar.gz: 0f2162ec01cb03476e918d62545a5fc9081000e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a688b780cffbef935aea3a5d7a6402c255e3933e91bb9367bd18b830a76669b209afdf9c74f4b97ce883e1aad1382b0f7df68592762ffe0f18665b6b196e2d29
|
7
|
+
data.tar.gz: 183fa3c3080f6de61da2d9d157666fa078ea094c025658993ed6e1097b7482bb8f61013148a13ebaf8b944695a1f623a5d4bb4891a87254523afd2c940a14722
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -148,8 +148,7 @@ All the functions are class methods
|
|
148
148
|
rate_limited_enqueue(klass, *params)
|
149
149
|
rate_limited_requeue(klass, *params)
|
150
150
|
````
|
151
|
-
Queue the job specified to the resque queue specified by `@queue`. `rate_limited_requeue` is intended for use when you need the job to be pushed back to the queue; there are two reasons to split this from `
|
152
|
-
`, but they are split to make testing with stubs easier.
|
151
|
+
Queue the job specified to the resque queue specified by `@queue`. `rate_limited_requeue` is intended for use when you need the job to be pushed back to the queue; there are two reasons to split this from `rate_limited_enqueue`. Firstly it makes testing with stubs easier - secondly there is a boundary condition when you need to requeue the last job in the queue.
|
153
152
|
|
154
153
|
```ruby
|
155
154
|
pause
|
@@ -57,7 +57,9 @@ module Resque
|
|
57
57
|
|
58
58
|
def paused?(unknown = false)
|
59
59
|
# parameter is what to return if the queue is empty, and so the state is unknown
|
60
|
-
if Resque.
|
60
|
+
if Resque.inline
|
61
|
+
false
|
62
|
+
elsif Resque.redis.exists(RESQUE_PREFIX + @queue.to_s)
|
61
63
|
false
|
62
64
|
elsif Resque.redis.exists(RESQUE_PREFIX + paused_queue_name)
|
63
65
|
true
|
@@ -118,6 +118,38 @@ describe Resque::Plugins::RateLimitedQueue do
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
describe 'when queue is paused and Resque is in inline mode' do
|
122
|
+
let(:resque_prefix) { Resque::Plugins::RateLimitedQueue::RESQUE_PREFIX }
|
123
|
+
let(:queue) { resque_prefix + RateLimitedTestQueue.queue_name_private }
|
124
|
+
let(:paused_queue) { resque_prefix + RateLimitedTestQueue.paused_queue_name }
|
125
|
+
|
126
|
+
before do
|
127
|
+
Resque.redis.stub(:exists).with(queue).and_return(false)
|
128
|
+
Resque.redis.stub(:exists).with(paused_queue).and_return(true)
|
129
|
+
Resque.inline = true
|
130
|
+
end
|
131
|
+
|
132
|
+
after do
|
133
|
+
Resque.inline = false
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'would be paused' do
|
137
|
+
expect(Resque.redis.exists(queue)).to eq false
|
138
|
+
expect(Resque.redis.exists(paused_queue)).to eq true
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'says it is not paused' do
|
142
|
+
expect(RateLimitedTestQueue.paused?).to eq false
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'performs the job' do
|
146
|
+
expect do
|
147
|
+
# Stack overflow unless handled
|
148
|
+
RateLimitedTestQueue.rate_limited_enqueue(RateLimitedTestQueue, true)
|
149
|
+
end.not_to raise_error
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
121
153
|
describe 'find_class' do
|
122
154
|
it 'works with symbol' do
|
123
155
|
RateLimitedTestQueue.find_class(RateLimitedTestQueue).should eq RateLimitedTestQueue
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-rate_limited_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Dowling
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: resque
|