Howler::Config
)gem 'howler'
in your Gemfile.bundle install
.[bundle exec] howler
.Howler listens to configuration and updates accordingly.
# Scale Workers
Howler::Config[:concurrency] = 75
class User [< ActiveRecord::Base]
async :fetch_content
def self.fetch_content(user_id)
...
end
end
User.async_fetch_content(user.id)
#=> true
def self.fetch_content(user_id)
user = User.find(user_id)
unless user.fetchable?
raise Howler::Message::Retry(:after => 1.minute, :ttl => 10.minutes)
end
... # fetch content
end
def self.fetch_content(user_id)
...
begin
# Try to fetch /home_timeline for the user
rescue Twitter::Error::ServiceUnavailable => error
raise Howler::Message::Notify.new(erorr)
end
... # process the timeline
end
def fetch_content(user_id)
... # done fetching content
Howler::Config[user_id] = {:fetched_at => Time.now, :status => 'success'}.to_json
# Then to delete a key simply assign nil
Howler::Config[user_id] = nil
end
Howler::Message::Notify
exceptionHowler
will take care of the rest.