Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #12 from nbibler/exceptions.

Gracefully log and return from Heroku-derived RestClient exceptions.
  • Loading branch information...
commit 24821b75084f1e0f48d26353d333977fbcf80e27 2 parents b88da81 + 9cabd12
@meskyanichi meskyanichi authored
View
2  lib/hirefire/environment/base.rb
@@ -60,7 +60,7 @@ class Base
# @return [nil]
def hire
jobs_count = jobs
- workers_count = workers
+ workers_count = workers || return
##
# Use "Standard Notation"
View
6 lib/hirefire/environment/heroku.rb
@@ -31,6 +31,12 @@ def workers(amount = nil)
# Sets the amount of Delayed Job
# workers that need to be running on Heroku
client.set_workers(ENV['APP_NAME'], amount)
+
+ rescue RestClient::Exception
+ # Heroku library uses rest-client, currently, and it is quite
+ # possible to receive RestClient exceptions through the client.
+ HireFire::Logger.message("Worker query request failed with #{ $!.class.name } #{ $!.message }")
+ nil
end
##
View
9 spec/environment_spec.rb
@@ -228,6 +228,15 @@ def jobs=(amount)
base.expects(:workers).with(5).never
base.hire
end
+
+ it 'should NEVER do API requests to Heroku if the workers query returns nil' do
+ base.jobs = 100
+ base.workers = nil
+
+ base.expects(:log_and_hire).never
+ base.expects(:fire).never
+ base.hire
+ end
end
describe 'the Lambda (functional) notation' do
Please sign in to comment.
Something went wrong with that request. Please try again.