resque-igo 1.12.1 → 1.12.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -73,7 +73,13 @@ module Resque
73
73
 
74
74
  #is it a hydra job?
75
75
  heads = klass.instance_variable_get(:@hydra)
76
- queue = (queue.to_s + rand(heads).to_s).to_sym if heads
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|
@@ -1,3 +1,3 @@
1
1
  module Resque
2
- Version = VERSION = '1.12.1'
2
+ Version = VERSION = '1.12.2'
3
3
  end
@@ -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
@@ -128,6 +128,12 @@ class HydraJob
128
128
  @hydra = 2
129
129
  end
130
130
 
131
+ class UniqueHydraJob
132
+ @queue = :hydra
133
+ @unique_jobs = true
134
+ @hydra = 100
135
+ end
136
+
131
137
  #some redgreen fun
132
138
  # -*- coding: utf-8 -*-
133
139
  begin
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: 37
4
+ hash: 35
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 12
9
- - 1
10
- version: 1.12.1
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-01 00:00:00 -05:00
18
+ date: 2010-12-03 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency