resque-throttler 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cc4d7ea16ce3914cd16f8c6bdc42bb43d391d3d
4
- data.tar.gz: 1315df0567f36ee68e14b4daf16f756552c871bf
3
+ metadata.gz: 09888d1679af9193b4323ac267b2d1488d911d8a
4
+ data.tar.gz: 287f898deb3c12a723527fe024645dd63f7821de
5
5
  SHA512:
6
- metadata.gz: 03d5c6177b891b30cab5b4ebe9b5e31de08db32790aa2c9c132fcac835c55a8734a843b31720f915536142d73e6ed620e027fa08138d3e428188df7f7677c0e1
7
- data.tar.gz: c1b0db2f23672b7e7566c64199dca70364ffc48342ed1922984c1739993a77940e79062e416c581f0ecc9f24d4913287045baea7f26f384097f3ab408751fc61
6
+ metadata.gz: b3150786f6c903bb11d1a4386ac943c681411f434a6f4bab42ff9d659bc20754ba762273d06d9de80c8b64a323fdb49333a6029dc7c188e4dc421fd9cbe4bde5
7
+ data.tar.gz: ecd025b6e2946ea1777af977ee399cc97259269820b2c6280dbed93bbec561544dff2a90ee4bca0678120392a47cd8a2c68ed1db2b81e6054ab819dba776d02a
@@ -67,14 +67,14 @@ class Resque::Job
67
67
 
68
68
  def perform_with_throttler
69
69
  if Resque.queue_rate_limited?(self.queue)
70
- uuid = SecureRandom.uuid
70
+ @throttler_uuid = SecureRandom.uuid
71
71
  begin
72
72
  # TODO this needs to be wrapped in a transcation
73
- redis.hmset("throttler:jobs:#{uuid}", "started_at", Time.now.to_i)
74
- redis.sadd("throttler:#{queue}_uuids", uuid)
73
+ redis.hmset("throttler:jobs:#{@throttler_uuid}", "started_at", Time.now.to_i)
74
+ redis.sadd("throttler:#{queue}_uuids", @throttler_uuid)
75
75
  perform_without_throttler
76
76
  ensure
77
- redis.hmset("throttler:jobs:#{uuid}", "ended_at", Time.now.to_i)
77
+ redis.hmset("throttler:jobs:#{@throttler_uuid}", "ended_at", Time.now.to_i)
78
78
  end
79
79
  else
80
80
  perform_without_throttler
@@ -83,4 +83,15 @@ class Resque::Job
83
83
  alias_method :perform_without_throttler, :perform
84
84
  alias_method :perform, :perform_with_throttler
85
85
 
86
+ # This is added for when there is a dirty exit
87
+ # TODO: testme
88
+ def fail_with_throttler(exception)
89
+ if defined?(@throttler_uuid)
90
+ redis.hmset("throttler:jobs:#{@throttler_uuid}", "ended_at", Time.now.to_i)
91
+ end
92
+ fail_without_throttler(exception)
93
+ end
94
+ alias_method :fail_without_throttler, :fail
95
+ alias_method :fail, :fail_with_throttler
96
+
86
97
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "resque-throttler"
3
- s.version = '0.1.1'
3
+ s.version = '0.1.4'
4
4
  s.licenses = ['MIT']
5
5
  s.authors = ["Jon Bracy"]
6
6
  s.email = ["jonbracy@gmail.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-throttler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy