Class: Qless::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/qless.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/qless.rb', line 141

def initialize(options = {})
  # This is the redis instance we're connected to
  @redis   = options[:redis] || Redis.connect(options) # use connect so REDIS_URL will be honored
  @options = options
  assert_minimum_redis_version("2.5.5")
  @config = Config.new(self)
  ['cancel', 'config', 'complete', 'depends', 'fail', 'failed', 'get', 'heartbeat', 'jobs', 'peek', 'pop',
    'priority', 'put', 'queues', 'recur', 'retry', 'stats', 'tag', 'track', 'workers'].each do |f|
    self.instance_variable_set("@_#{f}", Lua.new(f, @redis))
  end
  
  @jobs    = ClientJobs.new(self)
  @queues  = ClientQueues.new(self)
  @workers = ClientWorkers.new(self)
end

Instance Attribute Details

#_cancelObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _cancel
  @_cancel
end

#_completeObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _complete
  @_complete
end

#_configObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _config
  @_config
end

#_dependsObject (readonly)

Returns the value of attribute _depends.



137
138
139
# File 'lib/qless.rb', line 137

def _depends
  @_depends
end

#_failObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _fail
  @_fail
end

#_failedObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _failed
  @_failed
end

#_getObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _get
  @_get
end

#_heartbeatObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _heartbeat
  @_heartbeat
end

#_jobsObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _jobs
  @_jobs
end

#_peekObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _peek
  @_peek
end

#_popObject (readonly)

Lua scripts



136
137
138
# File 'lib/qless.rb', line 136

def _pop
  @_pop
end

#_priorityObject (readonly)

Returns the value of attribute _priority.



137
138
139
# File 'lib/qless.rb', line 137

def _priority
  @_priority
end

#_putObject (readonly)

Returns the value of attribute _put.



137
138
139
# File 'lib/qless.rb', line 137

def _put
  @_put
end

#_queuesObject (readonly)

Returns the value of attribute _queues.



137
138
139
# File 'lib/qless.rb', line 137

def _queues
  @_queues
end

#_recurObject (readonly)

Returns the value of attribute _recur.



137
138
139
# File 'lib/qless.rb', line 137

def _recur
  @_recur
end

#_retryObject (readonly)

Returns the value of attribute _retry.



137
138
139
# File 'lib/qless.rb', line 137

def _retry
  @_retry
end

#_statsObject (readonly)

Returns the value of attribute _stats.



137
138
139
# File 'lib/qless.rb', line 137

def _stats
  @_stats
end

#_tagObject (readonly)

Returns the value of attribute _tag.



137
138
139
# File 'lib/qless.rb', line 137

def _tag
  @_tag
end

#_trackObject (readonly)

Returns the value of attribute _track.



137
138
139
# File 'lib/qless.rb', line 137

def _track
  @_track
end

#_workersObject (readonly)

Returns the value of attribute _workers.



137
138
139
# File 'lib/qless.rb', line 137

def _workers
  @_workers
end

#configObject (readonly)

A real object



139
140
141
# File 'lib/qless.rb', line 139

def config
  @config
end

#jobsObject (readonly)

A real object



139
140
141
# File 'lib/qless.rb', line 139

def jobs
  @jobs
end

#queuesObject (readonly)

A real object



139
140
141
# File 'lib/qless.rb', line 139

def queues
  @queues
end

#redisObject (readonly)

A real object



139
140
141
# File 'lib/qless.rb', line 139

def redis
  @redis
end

#workersObject (readonly)

A real object



139
140
141
# File 'lib/qless.rb', line 139

def workers
  @workers
end

Instance Method Details

#eventsObject



161
162
163
164
165
166
# File 'lib/qless.rb', line 161

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

#inspectObject



157
158
159
# File 'lib/qless.rb', line 157

def inspect
  "<Qless::Client #{@options} >"
end

#tags(offset = 0, count = 100) ⇒ Object



176
177
178
# File 'lib/qless.rb', line 176

def tags(offset=0, count=100)
  JSON.parse(@_tag.call([], ['top', offset, count]))
end

#track(jid) ⇒ Object



168
169
170
# File 'lib/qless.rb', line 168

def track(jid)
  @_track.call([], ['track', jid, Time.now.to_i])
end

#untrack(jid) ⇒ Object



172
173
174
# File 'lib/qless.rb', line 172

def untrack(jid)
  @_track.call([], ['untrack', jid, Time.now.to_i])
end