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



132
133
134
135
136
137
# File 'lib/resque/integration.rb', line 132

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



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

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

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

  extend Resque::Plugins::Retry

  @retry_limit = options.fetch(:limit, 2)
  @retry_delay = options.fetch(:delay, 60)
  @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