class AllQ::Client
Represents the client singleton
Constants
- URL
Public Class Methods
new(url = nil)
click to toggle source
# File lib/allq/client.rb, line 8 def initialize(url = nil) @url = url.nil? ? URL : url @connection = nil reload! end
Public Instance Methods
add_server(server_url)
click to toggle source
# File lib/allq/client.rb, line 28 def add_server(server_url) @add_server_action.snd(server_url: server_url) end
bury(job)
click to toggle source
# File lib/allq/client.rb, line 52 def bury(job) raise "Can't 'bury' a Job that is nil. Please check for Nil job before burying." unless job @bury_action.snd(job_id: job.id) end
clear(cache_type = "cache_type", value = "all")
click to toggle source
# File lib/allq/client.rb, line 40 def clear(cache_type = "cache_type", value = "all") @clear_action.snd(cache_type: :all) end
close()
click to toggle source
# File lib/allq/client.rb, line 102 def close @connection.close end
delete(job)
click to toggle source
# File lib/allq/client.rb, line 73 def delete(job) raise "Can't delete a Nil job" unless job @delete_action.snd(job_id: job.id) end
done(job)
click to toggle source
# File lib/allq/client.rb, line 78 def done(job) raise "Can't set 'done' on a Job that is nil. Please check for Nil job before setting done." unless job @done_action.snd(job_id: job.id) end
drain(server_id)
click to toggle source
# File lib/allq/client.rb, line 32 def drain(server_id) @drain_action.snd(server_id: server_id) end
get(tube_name)
click to toggle source
# File lib/allq/client.rb, line 57 def get(tube_name) @get_action.snd(tube_name) end
kick(job)
click to toggle source
# File lib/allq/client.rb, line 36 def kick(job) @kick_action.snd(job: job) end
parent_job(tube, body, ttl: 3600, delay: 0, parent_id: nil, priority: 5, limit: nil, noop: false)
click to toggle source
# File lib/allq/client.rb, line 14 def parent_job(tube, body, ttl: 3600, delay: 0, parent_id: nil, priority: 5, limit: nil, noop: false) data = { 'body' => body, 'tube' => tube, 'delay' => delay, 'ttl' => ttl, 'priority' => priority, 'parent_id' => parent_id, 'limit' => limit, 'noop' => noop } @parent_job_action.snd(data) end
peek(tube_name)
click to toggle source
# File lib/allq/client.rb, line 44 def peek(tube_name) @peek_action.snd(tube: tube_name, buried: false) end
peek_buried(tube_name)
click to toggle source
# File lib/allq/client.rb, line 48 def peek_buried(tube_name) @peek_action.snd(tube: tube_name, buried: true) end
put(tube, body, ttl: 3600, delay: 0, parent_id: nil, priority: 5)
click to toggle source
# File lib/allq/client.rb, line 61 def put(tube, body, ttl: 3600, delay: 0, parent_id: nil, priority: 5) data = { 'body' => body, 'tube' => tube, 'delay' => delay, 'ttl' => ttl, 'priority' => priority, 'parent_id' => parent_id } @put_action.snd(data) end
release(job, delay)
click to toggle source
# File lib/allq/client.rb, line 92 def release(job, delay) raise "Can't 'release' a Job that is nil." unless job raise "Delay must be a int" unless delay.is_a?(Integer) @release_action.snd(job_id: job.id, delay: delay) end
reload!()
click to toggle source
# File lib/allq/client.rb, line 106 def reload! @connection.close if @connection puts "AllQ Connection Started --#{@url}" @connection = AllQ::Connection.new(@url) @get_action = AllQ::Get.new(@connection, self) @drain_action = AllQ::Drain.new(@connection, self) @add_server_action = AllQ::AddServer.new(@connection, self) @put_action = AllQ::Put.new(@connection, self) @done_action = AllQ::Done.new(@connection, self) @stats_action = AllQ::Stats.new(@connection, self) @release_action = AllQ::Release.new(@connection, self) @touch_action = AllQ::Touch.new(@connection, self) @kick_action = AllQ::Kick.new(@connection, self) @bury_action = AllQ::Bury.new(@connection, self) @clear_action = AllQ::Clear.new(@connection, self) @peek_action = AllQ::Peek.new(@connection, self) @delete_action = AllQ::Delete.new(@connection, self) @parent_job_action = AllQ::ParentJob.new(@connection, self) @throttle_action = AllQ::Throttle.new(@connection, self) end
stats(breakout = false)
click to toggle source
# File lib/allq/client.rb, line 88 def stats(breakout = false) v = @stats_action.snd(breakout: breakout) end
throttle(tube, tps)
click to toggle source
# File lib/allq/client.rb, line 98 def throttle(tube, tps) @throttle_action.snd(name: tube, tps: tps) end
touch(job)
click to toggle source
# File lib/allq/client.rb, line 83 def touch(job) raise "Can't 'touch' a Job that is nil. Please check for Nil job before 'touch'." unless job @touch_action.snd(job_id: job.id) end