class Qless::Client
The client for interacting with Qless
Attributes
_qless[R]
Lua script
config[R]
Lua script
jobs[R]
Lua script
queues[R]
Lua script
redis[R]
Lua script
worker_name[RW]
workers[R]
Lua script
Public Class Methods
new(options = {})
click to toggle source
# File lib/qless.rb, line 175 def initialize(options = {}) # This is the redis instance we're connected to. Use connect so REDIS_URL # will be honored @redis = options[:redis] || Redis.connect(options) @options = options assert_minimum_redis_version('2.5.5') @config = Config.new(self) @_qless = Qless::LuaScript.new('qless', @redis) @jobs = ClientJobs.new(self) @queues = ClientQueues.new(self) @workers = ClientWorkers.new(self) @worker_name = [Socket.gethostname, Process.pid.to_s].join('-') end
Public Instance Methods
==(other)
click to toggle source
# File lib/qless.rb, line 235 def ==(other) self.class == other.class && redis.id == other.redis.id end
Also aliased as: eql?
bulk_cancel(jids)
click to toggle source
# File lib/qless.rb, line 221 def bulk_cancel(jids) call('cancel', jids) end
call(command, *argv)
click to toggle source
# File lib/qless.rb, line 201 def call(command, *argv) @_qless.call(command, Time.now.to_f, *argv) end
deregister_workers(*worker_names)
click to toggle source
# File lib/qless.rb, line 217 def deregister_workers(*worker_names) call('worker.deregister', *worker_names) end
events()
click to toggle source
# File lib/qless.rb, line 194 def events # Events needs its own redis instance of the same configuration, because # once it's subscribed, we can only use pub-sub-like commands. This way, # we still have access to the client in the normal case @events ||= ClientEvents.new(Redis.connect(@options)) end
hash()
click to toggle source
# File lib/qless.rb, line 240 def hash self.class.hash ^ redis.id.hash end
inspect()
click to toggle source
# File lib/qless.rb, line 190 def inspect "<Qless::Client #{@options} >" end
new_redis_connection()
click to toggle source
# File lib/qless.rb, line 226 def new_redis_connection redis.dup end
track(jid)
click to toggle source
# File lib/qless.rb, line 205 def track(jid) call('track', 'track', jid) end
untrack(jid)
click to toggle source
# File lib/qless.rb, line 209 def untrack(jid) call('track', 'untrack', jid) end
Private Instance Methods
assert_minimum_redis_version(version)
click to toggle source
# File lib/qless.rb, line 246 def assert_minimum_redis_version(version) # remove the "-pre2" from "2.6.8-pre2" redis_version = @redis.info.fetch('redis_version').split('-').first return if Gem::Version.new(redis_version) >= Gem::Version.new(version) raise UnsupportedRedisVersionError, "Qless requires #{version} or better, not #{redis_version}" end