module Delayed::Backend::Ironmq::Actions
Public Instance Methods
after_fork()
click to toggle source
# File lib/delayed/backend/actions.rb, line 21 def after_fork end
before_fork()
click to toggle source
# File lib/delayed/backend/actions.rb, line 18 def before_fork end
clear_locks!(*args)
click to toggle source
No need to check locks
# File lib/delayed/backend/actions.rb, line 55 def clear_locks!(*args) true end
db_time_now()
click to toggle source
# File lib/delayed/backend/actions.rb, line 24 def db_time_now Time.now.utc end
delete_all()
click to toggle source
# File lib/delayed/backend/actions.rb, line 40 def delete_all deleted = 0 Delayed::Worker.available_priorities.each do |priority| loop do msgs = ironmq.queue(queue_name(priority)).get(:n => 1000) break if msgs.blank? msgs.each do |msg| msg.delete deleted += 1 end end end end
field(name, options = {})
click to toggle source
# File lib/delayed/backend/actions.rb, line 5 def field(name, options = {}) #type = options[:type] || String default = options[:default] || nil define_method name do @attributes ||= {} @attributes[name.to_sym] || default end define_method "#{name}=" do |value| @attributes ||= {} @attributes[name.to_sym] = value end end
find_available(worker_name, limit = 5, max_run_time = Worker.max_run_time)
click to toggle source
def self.queue_name
Delayed::Worker.queue_name
end
# File lib/delayed/backend/actions.rb, line 32 def find_available(worker_name, limit = 5, max_run_time = Worker.max_run_time) Delayed::Worker.available_priorities.each do |priority| message = ironmq.queue(queue_name(priority)).get return [Delayed::Backend::Ironmq::Job.new(message)] if message end [] end
Private Instance Methods
ironmq()
click to toggle source
# File lib/delayed/backend/actions.rb, line 61 def ironmq ::Delayed::Worker.ironmq end
queue_name(priority)
click to toggle source
# File lib/delayed/backend/actions.rb, line 65 def queue_name(priority) "#{Delayed::Worker.queue_name}_#{priority || 0}" end