resque-priority-jobs 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/resque-priority-jobs.rb
CHANGED
|
@@ -2,6 +2,8 @@ require 'resque'
|
|
|
2
2
|
require 'resque-priority-jobs/queue'
|
|
3
3
|
require 'resque-priority-jobs/multi_queue'
|
|
4
4
|
require 'resque-priority-jobs/job'
|
|
5
|
+
require 'resque-priority-jobs/failure'
|
|
6
|
+
require 'resque-priority-jobs/failure/redis'
|
|
5
7
|
|
|
6
8
|
# Max priority is the highest priority similarly for min priority. These numbers are arbitrary
|
|
7
9
|
MIN_PRIORITY = 20
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Resque
|
|
2
|
+
module Failure
|
|
3
|
+
class Redis < Base
|
|
4
|
+
def self.requeue_with_priority(index)
|
|
5
|
+
item = all(index)
|
|
6
|
+
item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
|
|
7
|
+
Resque.redis.lset(:failed, index, Resque.encode(item))
|
|
8
|
+
if item['payload']['priority']
|
|
9
|
+
Job.create_with_priority(item['queue'], item['payload']['class'], item['payload']['priority'], *item['payload']['args'])
|
|
10
|
+
else
|
|
11
|
+
Job.create(item['queue'], item['payload']['class'], *item['payload']['args'])
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -4,7 +4,7 @@ module Resque
|
|
|
4
4
|
#FIXME: Not implemented Resque.inline?
|
|
5
5
|
def self.create_with_priority queue, klass, priority, *args
|
|
6
6
|
Resque.validate(klass, queue)
|
|
7
|
-
Resque.push_with_priority(queue, priority, :class => klass.to_s, :args => args)
|
|
7
|
+
Resque.push_with_priority(queue, priority, :class => klass.to_s, :args => args, :priority => priority)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -7,6 +7,17 @@ module Resque
|
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
def push object
|
|
11
|
+
raise QueueDestroyed if destroyed?
|
|
12
|
+
return push_with_priority object['priority'].to_i, object if object['priority']
|
|
13
|
+
synchronize do
|
|
14
|
+
@redis.rpush @redis_name, encode(object)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
alias :<< :push
|
|
19
|
+
alias :enq :push
|
|
20
|
+
|
|
10
21
|
# remove entry from queue use default pop in case of non-priority queue see alias_method_chain
|
|
11
22
|
def pop_with_priority non_block = false
|
|
12
23
|
return pop_without_priority non_block unless is_a_priority_queue?
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: resque-priority-jobs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.2.
|
|
5
|
+
version: 0.2.2
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- rajofchennai
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2012-09
|
|
13
|
+
date: 2012-10-09 00:00:00 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: resque
|
|
@@ -72,6 +72,8 @@ files:
|
|
|
72
72
|
- README.md
|
|
73
73
|
- Rakefile
|
|
74
74
|
- lib/resque-priority-jobs.rb
|
|
75
|
+
- lib/resque-priority-jobs/failure.rb
|
|
76
|
+
- lib/resque-priority-jobs/failure/redis.rb
|
|
75
77
|
- lib/resque-priority-jobs/job.rb
|
|
76
78
|
- lib/resque-priority-jobs/multi_queue.rb
|
|
77
79
|
- lib/resque-priority-jobs/queue.rb
|