Module: Resque::Integration::ClassMethods

Defined in:
lib/resque/integration.rb

Instance Method Summary collapse

Instance Method Details

#continuousObject

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(options = {})
  extend Ordered

  self.max_iterations = options.fetch(:max_iterations, 20)
  self.uniqueness = Ordered::Uniqueness.new(&options[:unique]) if options.key?(:unique)
end

#prioritizedObject



140
141
142
# File 'lib/resque/integration.rb', line 140

def prioritized
  extend Priority
end

#priority?Boolean

Public: job used priority queues

Returns:

  • (Boolean)


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(options = {})
  raise '`retries` should be declared higher in code than `unique`' if unique?

  extend Resque::Plugins::Retry

  @retry_limit = options.fetch(:limit, 2)
  @retry_delay = options.fetch(:delay, 60)

  @retry_exceptions = options[:exceptions] if options.key? :exceptions

  if options[: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 = options.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

Returns:

  • (Boolean)


92
93
94
# File 'lib/resque/integration.rb', line 92

def unique?
  false
end