Module: Resque::Integration::ClassMethods
- Defined in:
- lib/resque/integration.rb
Instance Method Summary collapse
-
#continuous ⇒ Object
Extend job with ‘continuous’ functionality so you can re-enqueue job with
continuemethod. -
#ordered(options = {}) ⇒ Object
Mark Job as ordered.
- #prioritized ⇒ Object
-
#priority? ⇒ Boolean
Public: job used priority queues.
-
#queue(name = nil) ⇒ Object
Get or set queue name (just a synonym to resque native methodology).
-
#retrys(options = {}) ⇒ Object
Extend resque-retry.
-
#unique(callback = nil, &block) ⇒ Object
Mark Job as unique and set given
callbackorblockas Unique Arguments procedure. - #unique? ⇒ Boolean
Instance Method Details
#continuous ⇒ Object
Extend job with ‘continuous’ functionality so you can re-enqueue job with continue method.
88 89 90 |
# File 'lib/resque/integration.rb', line 88 def continuous extend Continuous end |
#ordered(options = {}) ⇒ Object
Mark Job as ordered
132 133 134 135 136 137 |
# File 'lib/resque/integration.rb', line 132 def ordered( = {}) extend Ordered self.max_iterations = .fetch(:max_iterations, 20) self.uniqueness = Ordered::Uniqueness.new(&[:unique]) if .key?(:unique) end |
#prioritized ⇒ Object
139 140 141 |
# File 'lib/resque/integration.rb', line 139 def prioritized extend Priority end |
#priority? ⇒ Boolean
Public: job used priority queues
97 98 99 |
# File 'lib/resque/integration.rb', line 97 def priority? false end |
#queue(name = nil) ⇒ Object
Get or set queue name (just a synonym to resque native methodology)
72 73 74 75 76 77 78 |
# File 'lib/resque/integration.rb', line 72 def queue(name = nil) if name @queue = name else @queue end end |
#retrys(options = {}) ⇒ Object
Extend resque-retry.
options - Hash
:limit - Integer (default: 2)
:delay - Integer (default: 60)
:expire_retry_key_after - Integer (default: 3200), истечение ключа в секундах. Если
t - среднее время выполнения одного джоба
n - текущее кол-во джобов в очереди
k - кол-во воркеров
то expire_retry_key_after >= t * n / k
Иначе ключ истечет, прежде чем джоб отработает.
Returns nothing
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/resque/integration.rb', line 119 def retrys( = {}) if unique? raise '`retrys` should be declared higher in code than `unique`' end extend Resque::Plugins::Retry @retry_limit = .fetch(:limit, 2) @retry_delay = .fetch(:delay, 60) @expire_retry_key_after = .fetch(:expire_retry_key_after, 1.hour.seconds) end |
#unique(callback = nil, &block) ⇒ Object
Mark Job as unique and set given callback or block as Unique Arguments procedure
81 82 83 84 85 |
# File 'lib/resque/integration.rb', line 81 def unique(callback = nil, &block) extend Unique unless unique? lock_on(&(callback || block)) end |
#unique? ⇒ Boolean
92 93 94 |
# File 'lib/resque/integration.rb', line 92 def unique? false end |