job_queue 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 10
3
- :major: 0
4
2
  :minor: 0
3
+ :patch: 11
4
+ :major: 0
@@ -39,6 +39,10 @@ class JobQueue::BeanstalkAdapter
39
39
  end
40
40
  rescue Beanstalk::TimedOut
41
41
  # Do nothing - retry to reseve (from another host?)
42
+ rescue Beanstalk::NotConnected
43
+ JobQueue.logger.fatal "Could not connect any beanstalk hosts. " \
44
+ "Retrying in 1s."
45
+ sleep 1
42
46
  rescue => e
43
47
  if job
44
48
  error_report.call(job.body, e)
@@ -211,6 +211,64 @@ describe JobQueue::BeanstalkAdapter do
211
211
  end
212
212
  end
213
213
 
214
+ describe "when no instances are available it should not kill the CPU by relentlessly trying to connect to beanstalk, rather it should retry and print a warning every second" do
215
+ it "(case that 0/1 instances available)" do
216
+ JobQueue.adapter = JobQueue::BeanstalkAdapter.new
217
+
218
+ system "killall beanstalkd"
219
+
220
+ JobQueue.logger.should_receive(:fatal).twice
221
+
222
+ begin
223
+ Timeout.timeout(1.1) do
224
+ JobQueue.subscribe do |job|
225
+ puts job
226
+ end
227
+ end
228
+ rescue Timeout::Error
229
+ nil
230
+ end
231
+ end
232
+
233
+ it "(case that 0/2 instances available)" do
234
+ JobQueue.adapter = JobQueue::BeanstalkAdapter.new({
235
+ :hosts => ['localhost:10001', 'localhost:10002']
236
+ })
237
+
238
+ system "killall beanstalkd"
239
+
240
+ JobQueue.logger.should_receive(:fatal).twice
241
+
242
+ begin
243
+ Timeout.timeout(1.1) do
244
+ JobQueue.subscribe do |job|
245
+ puts job
246
+ end
247
+ end
248
+ rescue Timeout::Error
249
+ nil
250
+ end
251
+ end
252
+
253
+ it "(case that 1/2 instances available)" do
254
+ JobQueue.adapter = JobQueue::BeanstalkAdapter.new({
255
+ :hosts => ['localhost:10001', 'localhost:10009']
256
+ })
257
+
258
+ JobQueue.logger.should_not_receive(:fatal)
259
+
260
+ begin
261
+ Timeout.timeout(1.1) do
262
+ JobQueue.subscribe do |job|
263
+ puts job
264
+ end
265
+ end
266
+ rescue Timeout::Error
267
+ nil
268
+ end
269
+ end
270
+ end
271
+
214
272
  describe "when connecting to one instance" do
215
273
  before :each do
216
274
  JobQueue.adapter = JobQueue::BeanstalkAdapter.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martyn Loughran
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-26 00:00:00 +01:00
12
+ date: 2009-09-02 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15