Class: Taskinator::Queues::ResqueAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/taskinator/queues/resque.rb

Defined Under Namespace

Classes: CreateProcessWorker, TaskWorker

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ ResqueAdapter

Returns a new instance of ResqueAdapter.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/taskinator/queues/resque.rb', line 11

def initialize(config={})
  config = Taskinator::Queues::DefaultConfig.merge(config)

  CreateProcessWorker.class_eval do
    @queue = config[:definition_queue]
  end

  TaskWorker.class_eval do
    @queue = config[:task_queue]
  end

end

Instance Method Details

#enqueue_create_process(definition, uuid, args) ⇒ Object



24
25
26
27
# File 'lib/taskinator/queues/resque.rb', line 24

def enqueue_create_process(definition, uuid, args)
  queue = definition.queue || Resque.queue_from_class(CreateProcessWorker)
  Resque.enqueue_to(queue, CreateProcessWorker, definition.name, uuid, Taskinator::Persistence.serialize(args))
end

#enqueue_task(task) ⇒ Object



29
30
31
32
# File 'lib/taskinator/queues/resque.rb', line 29

def enqueue_task(task)
  queue = task.queue || Resque.queue_from_class(TaskWorker)
  Resque.enqueue_to(queue, TaskWorker, task.uuid)
end