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
continue
method. -
#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
(also: #retries)
Extend resque-retry.
-
#unique(callback = nil, &block) ⇒ Object
Mark Job as unique and set given
callback
orblock
as 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
133 134 135 136 137 138 |
# File 'lib/resque/integration.rb', line 133 def ordered( = {}) extend Ordered self.max_iterations = .fetch(:max_iterations, 20) self.uniqueness = Ordered::Uniqueness.new(&[:unique]) if .key?(:unique) end |
#prioritized ⇒ Object
140 141 142 |
# File 'lib/resque/integration.rb', line 140 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 Also known as: retries
Extend resque-retry.
options - Hash of retry options (default: {}):
:limit - Integer max number of retry attempts (default: 2)
:delay - Integer seconds between retry attempts (default: 60)
:exceptions - Array or Hash of specific exceptions to retry (optional)
:temporary - boolean retry on temporary exceptions list (default: false)
:expire_retry_key_after - Integer expire of retry key in redis (default: 3200)
Returns nothing.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/resque/integration.rb', line 111 def retrys( = {}) raise '`retries` should be declared higher in code than `unique`' if unique? extend Resque::Plugins::Retry @retry_limit = .fetch(:limit, 2) @retry_delay = .fetch(:delay, 60) @retry_exceptions = [:exceptions] if .key? :exceptions if [:temporary] @retry_exceptions = @retry_exceptions && @retry_exceptions.dup || {} @retry_exceptions = @retry_exceptions.product([@retry_delay]).to_h if @retry_exceptions.is_a? Array @retry_exceptions.reverse_merge!(Resque.config.temporary_exceptions) end @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 |