Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleanup whitespace.

  • Loading branch information...
commit f05d1f971d16429a3845d0ad072f23c626bc8aa7 1 parent 4cfcbc6
@myronmarston myronmarston authored
Showing with 18 additions and 18 deletions.
  1. +17 −17 lib/qless/queue.rb
  2. +1 −1  spec/unit/queue_spec.rb
View
34 lib/qless/queue.rb
@@ -9,50 +9,50 @@ def initialize(name, client)
@name = name
@client = client
end
-
+
def running(start=0, count=25)
@client._jobs.call([], ['running', Time.now.to_f, @name, start, count])
end
-
+
def stalled(start=0, count=25)
@client._jobs.call([], ['stalled', Time.now.to_f, @name, start, count])
end
-
+
def scheduled(start=0, count=25)
@client._jobs.call([], ['scheduled', Time.now.to_f, @name, start, count])
end
-
+
def depends(start=0, count=25)
@client._jobs.call([], ['depends', Time.now.to_f, @name, start, count])
end
-
+
def recurring(start=0, count=25)
@client._jobs.call([], ['recurring', Time.now.to_f, @name, start, count])
end
end
-
+
class Queue
attr_reader :name
attr_accessor :worker_name
-
+
def initialize(name, client)
@client = client
@name = name
self.worker_name = Qless.worker_name
end
-
+
def jobs
@jobs ||= QueueJobs.new(@name, @client)
end
-
+
def counts
JSON.parse(@client._queues.call([], [Time.now.to_i, @name]))
end
-
+
def heartbeat
@client.config["#{@name}-heartbeat"]
end
-
+
def heartbeat=(value)
@client.config["#{@name}-heartbeat"] = value
end
@@ -64,7 +64,7 @@ def pause
def unpause
@client._unpause.call([], [name])
end
-
+
# Put the described job in this queue
# Options include:
# => priority (int)
@@ -85,7 +85,7 @@ def put(klass, data, opts={})
'depends', JSON.generate(opts.fetch(:depends, []))
])
end
-
+
# Make a recurring job in this queue
# Options include:
# => priority (int)
@@ -108,23 +108,23 @@ def recur(klass, data, interval, opts={})
'retries', opts.fetch(:retries, 5)
])
end
-
+
# Pop a work item off the queue
def pop(count=nil)
results = @client._pop.call([@name], [worker_name, (count || 1), Time.now.to_f]).map { |j| Job.new(@client, JSON.parse(j)) }
count.nil? ? results[0] : results
end
-
+
# Peek at a work item
def peek(count=nil)
results = @client._peek.call([@name], [(count || 1), Time.now.to_f]).map { |j| Job.new(@client, JSON.parse(j)) }
count.nil? ? results[0] : results
end
-
+
def stats(date=nil)
JSON.parse(@client._stats.call([], [@name, (date || Time.now.to_f)]))
end
-
+
# How many items in the queue?
def length
(@client.redis.multi do
View
2  spec/unit/queue_spec.rb
@@ -25,7 +25,7 @@ module Qless
string.should include("queue-name")
end
end
-
+
it "can specify a jid in put and recur" do
client.queues['foo'].put( Qless::Job, {'foo' => 'bar'}, :jid => 'howdy').should eq('howdy')
client.queues['foo'].recur(Qless::Job, {'foo' => 'bar'}, 5, :jid => 'hello').should eq('hello')
Please sign in to comment.
Something went wrong with that request. Please try again.