worker_roulette 0.0.2 → 0.0.3

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.
@@ -14,7 +14,7 @@ module WorkerRoulette
14
14
  @pubsub_pool.with do |redis|
15
15
  redis.subscribe(WorkerRoulette::JOB_NOTIFICATIONS) do |on|
16
16
  on.subscribe {on_subscribe_callback.call if on_subscribe_callback}
17
- on.message {redis.unsubscribe; block.call(work_orders!) if block}
17
+ on.message {block.call(work_orders!) if block}
18
18
  end
19
19
  end
20
20
  end
@@ -31,6 +31,10 @@ module WorkerRoulette
31
31
  end
32
32
  end
33
33
 
34
+ def unsubscribe
35
+ @pubsub_pool.with {|redis| redis.unsubscribe}
36
+ end
37
+
34
38
  private
35
39
  def get_sender_for_next_job(redis)
36
40
  @sender = (redis.zrange(WorkerRoulette::JOB_BOARD, 0, 0) || []).first.to_s
@@ -1,3 +1,3 @@
1
1
  module WorkerRoulette
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -142,7 +142,7 @@ describe WorkerRoulette do
142
142
  it "should get the work_orders from the next sender's slot when a new job is ready" do
143
143
  subject.work_orders!
144
144
  subject.should_receive(:work_orders!).and_call_original
145
- publisher = -> {foreman.enqueue_work_order(work_orders)}
145
+ publisher = -> {foreman.enqueue_work_order(work_orders); subject.unsubscribe; }
146
146
  subject.wait_for_work_orders(publisher) do |redis_work_orders|
147
147
  redis_work_orders.should == [work_orders_with_headers]
148
148
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worker_roulette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2014-02-12 00:00:00.000000000 Z
12
+ date: 2014-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis