Class: Resque::Job
- Inherits:
-
Object
- Object
- Resque::Job
- Defined in:
- lib/resque/throttler.rb
Instance Method Summary collapse
-
#fail_with_throttler(exception) ⇒ Object
(also: #fail)
This is added for when there is a dirty exit TODO: testme.
- #perform_with_throttler ⇒ Object (also: #perform)
Instance Method Details
#fail_with_throttler(exception) ⇒ Object Also known as: fail
This is added for when there is a dirty exit TODO: testme
88 89 90 91 92 93 |
# File 'lib/resque/throttler.rb', line 88 def fail_with_throttler(exception) if defined?(@throttler_uuid) redis.hmset("throttler:jobs:#{@throttler_uuid}", "ended_at", Time.now.to_i) end fail_without_throttler(exception) end |
#perform_with_throttler ⇒ Object Also known as: perform
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/resque/throttler.rb', line 68 def perform_with_throttler if Resque.queue_rate_limited?(self.queue) @throttler_uuid = SecureRandom.uuid begin # TODO this needs to be wrapped in a transcation redis.hmset("throttler:jobs:#{@throttler_uuid}", "started_at", Time.now.to_i) redis.sadd("throttler:#{queue}_uuids", @throttler_uuid) perform_without_throttler ensure redis.hmset("throttler:jobs:#{@throttler_uuid}", "ended_at", Time.now.to_i) end else perform_without_throttler end end |