Class: Sidekiq::Congestion::Request
- Inherits:
-
Object
- Object
- Sidekiq::Congestion::Request
- Extended by:
- Forwardable
- Defined in:
- lib/sidekiq/congestion/request.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#options ⇒ Object
Returns the value of attribute options.
-
#worker ⇒ Object
Returns the value of attribute worker.
Instance Method Summary collapse
- #congestion ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(worker, job, queue) ⇒ Request
constructor
A new instance of Request.
- #key ⇒ Object
- #reschedule! ⇒ Object
- #reschedule? ⇒ Boolean
Constructor Details
#initialize(worker, job, queue) ⇒ Request
Returns a new instance of Request.
13 14 15 16 17 18 |
# File 'lib/sidekiq/congestion/request.rb', line 13 def initialize(worker, job, queue) self.worker = worker self.args = job['args'] opts = worker. || { } self. = opts['congestion'] end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
7 8 9 |
# File 'lib/sidekiq/congestion/request.rb', line 7 def args @args end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/sidekiq/congestion/request.rb', line 7 def @options end |
#worker ⇒ Object
Returns the value of attribute worker.
7 8 9 |
# File 'lib/sidekiq/congestion/request.rb', line 7 def worker @worker end |
Instance Method Details
#congestion ⇒ Object
43 44 45 |
# File 'lib/sidekiq/congestion/request.rb', line 43 def congestion @congestion ||= ::Congestion.request key, end |
#enabled? ⇒ Boolean
20 21 22 |
# File 'lib/sidekiq/congestion/request.rb', line 20 def enabled? !! && _enabled? end |
#key ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sidekiq/congestion/request.rb', line 32 def key @key ||= case [:key] when Proc [:key].call *args when String, Symbol [:key].to_s else worker.class.name end end |
#reschedule! ⇒ Object
28 29 30 |
# File 'lib/sidekiq/congestion/request.rb', line 28 def reschedule! worker.class.perform_in backoff, *args end |
#reschedule? ⇒ Boolean
24 25 26 |
# File 'lib/sidekiq/congestion/request.rb', line 24 def reschedule? rejection_method == :reschedule end |