Module: BackgroundQueue::ClientLib::Command

Defined in:
lib/background_queue/client_lib/command.rb

Overview

store a command and all its parameters as a hash to be serialized when passing to the server.

Class Method Summary collapse

Class Method Details

.add_task_command(worker, owner_id, job_id, task_id, priority, task_parameters = {}, options = {}) ⇒ Object

create an ‘add task’ command



9
10
11
# File 'lib/background_queue/client_lib/command.rb', line 9

def self.add_task_command(worker, owner_id, job_id, task_id, priority, task_parameters={}, options={} )
  BackgroundQueue::Command.new(:add_task, options, :worker=>worker, :owner_id=>owner_id, :job_id=>job_id, :task_id=>task_id, :priority=>priority, :params=>task_parameters)
end

.add_tasks_command(worker, owner_id, job_id, tasks, priority, shared_parameters = {}, options = {}) ⇒ Object

create an ‘add tasks’ command



14
15
16
17
# File 'lib/background_queue/client_lib/command.rb', line 14

def self.add_tasks_command(worker, owner_id, job_id, tasks, priority, shared_parameters={}, options={} )
  raise BackgroundQueue::InvalidCommand, "No Tasks In List" if tasks.nil? || tasks.length == 0
  BackgroundQueue::Command.new(:add_tasks, options, :worker=>worker, :owner_id=>owner_id, :job_id=>job_id, :tasks=>tasks, :priority=>priority, :shared_parameters=>shared_parameters)
end

.get_status_command(job_id, options = {}) ⇒ Object

create an ‘get_status’ command



20
21
22
# File 'lib/background_queue/client_lib/command.rb', line 20

def self.get_status_command(job_id, options={} )
  BackgroundQueue::Command.new(:get_status, options, {:job_id=>job_id})
end

.stats_command(options = {}) ⇒ Object

create an ‘stats’ command



25
26
27
# File 'lib/background_queue/client_lib/command.rb', line 25

def self.stats_command(options={})
  BackgroundQueue::Command.new(:stats, options, {})
end