Class: Resque::Catridge
- Inherits:
-
Object
- Object
- Resque::Catridge
- Defined in:
- lib/resque/catridge.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
- .misfire_codes ⇒ Object
- .misfire_stats(status) ⇒ Object
- .misfire_stats_reset(status, request) ⇒ Object
- .ns ⇒ Object
-
.redis ⇒ Object
DI here, please.
- .reset_stats ⇒ Object
- .stats ⇒ Object
Instance Method Summary collapse
-
#initialize(request, response) ⇒ Catridge
constructor
A new instance of Catridge.
- #reload? ⇒ Boolean
- #retries ⇒ Object
Constructor Details
#initialize(request, response) ⇒ Catridge
Returns a new instance of Catridge.
5 6 7 8 9 10 |
# File 'lib/resque/catridge.rb', line 5 def initialize(request, response) @request = request @response = response log if misfire? inc_stat_counter end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
3 4 5 |
# File 'lib/resque/catridge.rb', line 3 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/resque/catridge.rb', line 3 def response @response end |
Class Method Details
.misfire_codes ⇒ Object
65 66 67 |
# File 'lib/resque/catridge.rb', line 65 def misfire_codes redis.keys "#{ns}:misfires:*" end |
.misfire_stats(status) ⇒ Object
69 70 71 72 |
# File 'lib/resque/catridge.rb', line 69 def misfire_stats(status) redis.hgetall "#{status}" #redis.hgetall "#{ns}:misfires:#{status}" end |
.misfire_stats_reset(status, request) ⇒ Object
74 75 76 77 |
# File 'lib/resque/catridge.rb', line 74 def misfire_stats_reset(status, request) redis.hdel "#{status}", "#{request}" #redis.hgetall "#{ns}:misfires:#{status}" end |
.ns ⇒ Object
52 53 54 |
# File 'lib/resque/catridge.rb', line 52 def ns 'kalashnikov' end |
.redis ⇒ Object
DI here, please
57 58 59 |
# File 'lib/resque/catridge.rb', line 57 def redis Resque.redis end |
.reset_stats ⇒ Object
79 80 81 82 83 84 |
# File 'lib/resque/catridge.rb', line 79 def reset_stats stats.keys.each do |http_code| redis.del "#{ns}:misfires:#{http_code}" end redis.del "#{ns}:stat" end |
.stats ⇒ Object
61 62 63 |
# File 'lib/resque/catridge.rb', line 61 def stats redis.hgetall "#{ns}:stat" end |
Instance Method Details
#reload? ⇒ Boolean
12 13 14 |
# File 'lib/resque/catridge.rb', line 12 def reload? misfire? && !ran_out_of_ammo? end |
#retries ⇒ Object
16 17 18 |
# File 'lib/resque/catridge.rb', line 16 def retries self.class.redis.hget("#{self.class.ns}:misfires:#{status}", serialized_request).to_i end |