Module: Resque

Defined in:
lib/resque-priority-jobs.rb,
lib/resque-priority-jobs/job.rb,
lib/resque-priority-jobs/queue.rb,
lib/resque-priority-jobs/failure.rb,
lib/resque-priority-jobs/version.rb,
lib/resque-priority-jobs/multi_queue.rb,
lib/resque-priority-jobs/failure/redis.rb

Defined Under Namespace

Modules: Failure, Priority Classes: Job, JobFetch, MultiQueue, Queue

Instance Method Summary collapse

Instance Method Details

#enqueue_with_priority(klass, priority = MIN_PRIORITY, *args) ⇒ Object

Queues which need priority scheduling need to use this method instead of enqueue FIXME: Known issue - If a use is already enqueued without priority and then we do a enqueue with priority we get an error of different datatype from redis.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/resque-priority-jobs.rb', line 15

def enqueue_with_priority(klass, priority = MIN_PRIORITY, *args)
  queue = queue_from_class(klass)
  before_hooks = Plugin.before_enqueue_hooks(klass).collect do |hook|
    klass.send(hook, *args)
  end
  return nil if before_hooks.any? { |result| result == false }

  Job.create_with_priority(queue, klass, priority, *args)

  Plugin.after_enqueue_hooks(klass).each do |hook|
    klass.send(hook, *args)
  end

  return true
end

#push_with_priority(queue, priority, item) ⇒ Object



31
32
33
# File 'lib/resque-priority-jobs.rb', line 31

def push_with_priority(queue, priority, item)
  queue(queue).push_with_priority priority, item
end