resque-igo 1.12.1 → 1.12.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/job.rb +7 -1
- data/lib/resque/version.rb +1 -1
- data/test/resque_test.rb +10 -0
- data/test/test_helper.rb +6 -0
- metadata +4 -4
data/lib/resque/job.rb
CHANGED
|
@@ -73,7 +73,13 @@ module Resque
|
|
|
73
73
|
|
|
74
74
|
#is it a hydra job?
|
|
75
75
|
heads = klass.instance_variable_get(:@hydra)
|
|
76
|
-
|
|
76
|
+
if heads
|
|
77
|
+
if item[:_id]
|
|
78
|
+
queue = (queue.to_s + (item[:_id].hash % heads).to_s).to_sym
|
|
79
|
+
else
|
|
80
|
+
queue = (queue.to_s + rand(heads).to_s).to_sym
|
|
81
|
+
end
|
|
82
|
+
end
|
|
77
83
|
|
|
78
84
|
ret = Resque.push(queue, item)
|
|
79
85
|
Plugin.after_enqueue_hooks(klass).each do |hook|
|
data/lib/resque/version.rb
CHANGED
data/test/resque_test.rb
CHANGED
|
@@ -348,4 +348,14 @@ context "Resque" do
|
|
|
348
348
|
assert(0 != Resque.size(:hydra1))
|
|
349
349
|
assert(0 != Resque.size(:hydra0))
|
|
350
350
|
end
|
|
351
|
+
|
|
352
|
+
test "hydra/unique hashes correctly" do
|
|
353
|
+
20.times do
|
|
354
|
+
Resque.enqueue(UniqueHydraJob, {:_id => 'zomgz', :one => 'one'})
|
|
355
|
+
end
|
|
356
|
+
# 'zomgz'.hash % 100 == 39
|
|
357
|
+
assert_equal(1, Resque.size(:hydra39))
|
|
358
|
+
Resque.enqueue(UniqueHydraJob, {:_id => '518', :one => 'one'})
|
|
359
|
+
assert_equal(2, Resque.size(:hydra39))
|
|
360
|
+
end
|
|
351
361
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: resque-igo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 35
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 12
|
|
9
|
-
-
|
|
10
|
-
version: 1.12.
|
|
9
|
+
- 2
|
|
10
|
+
version: 1.12.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Nathan D Acuff
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-12-
|
|
18
|
+
date: 2010-12-03 00:00:00 -05:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|