resque-status 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/resque/plugins/status.rb +7 -11
- data/lib/resque/plugins/status/hash.rb +5 -5
- data/resque-status.gemspec +2 -2
- data/test/test_helper.rb +1 -3
- metadata +5 -2
@@ -28,12 +28,13 @@ module Resque
|
|
28
28
|
# This job would iterate num times updating the status as it goes. At the end
|
29
29
|
# we update the status telling anyone listening to this job that its complete.
|
30
30
|
module Status
|
31
|
-
VERSION = '0.4.
|
31
|
+
VERSION = '0.4.1'
|
32
32
|
|
33
33
|
autoload :Hash, 'resque/plugins/status/hash'
|
34
34
|
|
35
35
|
# The error class raised when a job is killed
|
36
36
|
class Killed < RuntimeError; end
|
37
|
+
class NotANumber < RuntimeError; end
|
37
38
|
|
38
39
|
attr_reader :uuid, :options
|
39
40
|
|
@@ -76,11 +77,7 @@ module Resque
|
|
76
77
|
# job_id = ExampleJob.create(:num => 100)
|
77
78
|
#
|
78
79
|
def create(options = {})
|
79
|
-
|
80
|
-
self.perform(nil, options)
|
81
|
-
else
|
82
|
-
self.enqueue(self, options)
|
83
|
-
end
|
80
|
+
self.enqueue(self, options)
|
84
81
|
end
|
85
82
|
|
86
83
|
# Adds a job of type <tt>klass<tt> to the queue with <tt>options<tt>.
|
@@ -124,11 +121,7 @@ module Resque
|
|
124
121
|
def perform(uuid=nil, options = {})
|
125
122
|
uuid ||= Resque::Plugins::Status::Hash.generate_uuid
|
126
123
|
instance = new(uuid, options)
|
127
|
-
|
128
|
-
instance.perform
|
129
|
-
else
|
130
|
-
instance.safe_perform!
|
131
|
-
end
|
124
|
+
instance.safe_perform!
|
132
125
|
instance
|
133
126
|
end
|
134
127
|
|
@@ -198,6 +191,9 @@ module Resque
|
|
198
191
|
# This will kill the job if it has been added to the kill list with
|
199
192
|
# <tt>Resque::Plugins::Status::Hash.kill()</tt>
|
200
193
|
def at(num, total, *messages)
|
194
|
+
if total.to_f <= 0.0
|
195
|
+
raise(NotANumber, "Called at() with total=#{total} which is not a number")
|
196
|
+
end
|
201
197
|
tick({
|
202
198
|
'num' => num,
|
203
199
|
'total' => total
|
@@ -94,15 +94,15 @@ module Resque
|
|
94
94
|
|
95
95
|
# Return the <tt>num</tt> most recent status/job UUIDs in reverse chronological order.
|
96
96
|
def self.status_ids(range_start = nil, range_end = nil)
|
97
|
-
|
98
|
-
# Because we want a reverse chronological order, we need to get a range starting
|
99
|
-
# by the higest negative number.
|
100
|
-
redis.zrevrange(set_key, 0, -1) || []
|
101
|
-
else
|
97
|
+
if range_end && range_start
|
102
98
|
# Because we want a reverse chronological order, we need to get a range starting
|
103
99
|
# by the higest negative number. The ordering is transparent from the API user's
|
104
100
|
# perspective so we need to convert the passed params
|
105
101
|
(redis.zrevrange(set_key, (range_start.abs), ((range_end || 1).abs)) || [])
|
102
|
+
else
|
103
|
+
# Because we want a reverse chronological order, we need to get a range starting
|
104
|
+
# by the higest negative number.
|
105
|
+
redis.zrevrange(set_key, 0, -1) || []
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
data/resque-status.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "resque-status"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aaron Quint"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-01-26"
|
13
13
|
s.description = "resque-status is an extension to the resque queue system that provides simple trackable jobs. It provides a Resque::Plugins::Status::Hash class which can set/get the statuses of jobs and a Resque::Plugins::Status class that when included provides easily trackable/killable jobs."
|
14
14
|
s.email = "aaron@quirkey.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_helper.rb
CHANGED
@@ -38,12 +38,11 @@ at_exit do
|
|
38
38
|
pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
|
39
39
|
puts "Killing test redis server..."
|
40
40
|
Process.kill("KILL", pid.to_i)
|
41
|
-
`rm -f #{dir}/dump.rdb`
|
42
41
|
exit exit_code
|
43
42
|
end
|
44
43
|
|
45
44
|
puts "Starting redis for testing at localhost:9736..."
|
46
|
-
`redis-server #{dir}/redis-test.conf`
|
45
|
+
`rm -f #{dir}/dump.rdb && redis-server #{dir}/redis-test.conf`
|
47
46
|
Resque.redis = 'localhost:9736/1'
|
48
47
|
|
49
48
|
#### Fixtures
|
@@ -72,7 +71,6 @@ class ErrorJob
|
|
72
71
|
end
|
73
72
|
|
74
73
|
class KillableJob
|
75
|
-
|
76
74
|
include Resque::Plugins::Status
|
77
75
|
|
78
76
|
def perform
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: resque
|
@@ -88,6 +88,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- - ! '>='
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
hash: -3693274209748855583
|
91
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
95
|
none: false
|
93
96
|
requirements:
|