Class: BackgroundQueue::Client
- Inherits:
-
Object
- Object
- BackgroundQueue::Client
- Defined in:
- lib/background_queue/client.rb
Overview
The main interface to the background queue from the client. this class will look after sending a command to the server, using a failover server if needed.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#add_task(worker, owner_id, job_id, task_id, priority, task_parameters = {}, options = {}, server = nil) ⇒ BackgroundQueue::ClientLib::JobHandle
Add a task to the background.
-
#add_tasks(worker, owner_id, job_id, tasks, priority, shared_parameters = {}, options = {}, server = nil) ⇒ Object
Add multiple tasks to the background, all with the same worker/owner/job.
- #get_stats(server, options = {}) ⇒ Object
- #get_status(job_handle, options = {}) ⇒ Object
-
#initialize(path) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(path) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/background_queue/client.rb', line 9 def initialize(path) @config = BackgroundQueue::ClientLib::Config.load_file(path) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/background_queue/client.rb', line 7 def config @config end |
Instance Method Details
#add_task(worker, owner_id, job_id, task_id, priority, task_parameters = {}, options = {}, server = nil) ⇒ BackgroundQueue::ClientLib::JobHandle
Add a task to the background
32 33 34 35 36 37 |
# File 'lib/background_queue/client.rb', line 32 def add_task(worker, owner_id, job_id, task_id, priority, task_parameters={}, ={}, server=nil ) job_id, task_id = generate_ids(worker, owner_id, job_id, task_id) result, server = send_command(BackgroundQueue::ClientLib::Command.add_task_command(worker, owner_id, job_id, task_id, priority, task_parameters, ), server) #the server currently either returns :ok or an exception would have been thrown BackgroundQueue::ClientLib::JobHandle.new(owner_id, job_id, server) end |
#add_tasks(worker, owner_id, job_id, tasks, priority, shared_parameters = {}, options = {}, server = nil) ⇒ Object
Add multiple tasks to the background, all with the same worker/owner/job
48 49 50 51 52 |
# File 'lib/background_queue/client.rb', line 48 def add_tasks(worker, owner_id, job_id, tasks, priority, shared_parameters={}, ={}, server=nil ) result, server = send_command(BackgroundQueue::ClientLib::Command.add_tasks_command(worker, owner_id, job_id, tasks, priority, shared_parameters, ), server) #the server currently either returns :ok or an exception would have been thrown BackgroundQueue::ClientLib::JobHandle.new(owner_id, job_id, server) end |
#get_stats(server, options = {}) ⇒ Object
59 60 61 62 |
# File 'lib/background_queue/client.rb', line 59 def get_stats(server, ={}) result, server = send_command(BackgroundQueue::ClientLib::Command.stats_command( ), server) result.args end |
#get_status(job_handle, options = {}) ⇒ Object
54 55 56 57 |
# File 'lib/background_queue/client.rb', line 54 def get_status(job_handle, ={}) result, server = send_command(BackgroundQueue::ClientLib::Command.get_status_command(job_handle.job_id, ), job_handle.server) result end |