freddy 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec35bbe29d804ef1930904b88277dc9bcd6722e7
4
- data.tar.gz: 045d21384a3ed02bbe66c41a01f25a5cde723c1e
3
+ metadata.gz: 0a41652a44eeac100da5b263e45cacf1d4d18bac
4
+ data.tar.gz: 42e617e90df278bb931646a89281fde4e155be51
5
5
  SHA512:
6
- metadata.gz: cc2ec82ebe76f48b5e78ac3a695d71d16d49ca42bc08762c4b8c2b35c9c66a86c48fb8e743601bfb31c3c580e4906404f60122fa44e0269de51c4c9485af43d9
7
- data.tar.gz: fdb43cf87cfdd043f785b827957b9309562a79637af82e9dccbacf62cc62f6f622e1b5b28019c55dda586fdcd2cc3803cbe101b7b81780267f3a6ae7addeddde
6
+ metadata.gz: 006202ca3ddeb5670e824319dad63e1e980bc733a8a4a667f8a5faa1544a5f0af6c828515bc8ceb3f38fdf9f8f332fd3c09e4d6a8feb07522bf0dc256bd12253
7
+ data.tar.gz: 7f0d305730a3a7824302c87bfc95845f75e68f646b6554d73edcc1484752a9431f4095be73b54292c85a7c06f2e266c77e743830e9877ba8aa89e3de30886244
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  else
9
9
  spec.name = "freddy"
10
10
  end
11
- spec.version = '0.4.7'
11
+ spec.version = '0.4.8'
12
12
  spec.authors = ["Urmas Talimaa"]
13
13
  spec.email = ["urmas.talimaa@gmail.com"]
14
14
  spec.description = %q{Messaging API}
@@ -1,3 +1,5 @@
1
+ require 'thread'
2
+
1
3
  class Freddy
2
4
  module Consumers
3
5
  class TapIntoConsumer
@@ -5,11 +7,12 @@ class Freddy
5
7
  @consume_thread_pool = consume_thread_pool
6
8
  @channel = channel
7
9
  @topic_exchange = @channel.topic(Freddy::FREDDY_TOPIC_EXCHANGE_NAME)
10
+ @mutex = Mutex.new
8
11
  end
9
12
 
10
13
  def consume(pattern, &block)
11
- consumer = create_queue(pattern).subscribe do |delivery|
12
- process_message(delivery, &block)
14
+ consumer = @mutex.synchronize do
15
+ create_consumer(pattern, &block)
13
16
  end
14
17
 
15
18
  ResponderHandler.new(consumer, @consume_thread_pool)
@@ -17,6 +20,13 @@ class Freddy
17
20
 
18
21
  private
19
22
 
23
+
24
+ def create_consumer(pattern, &block)
25
+ create_queue(pattern).subscribe do |delivery|
26
+ process_message(delivery, &block)
27
+ end
28
+ end
29
+
20
30
  def create_queue(pattern)
21
31
  @channel
22
32
  .queue('', exclusive: true)
@@ -62,4 +62,15 @@ describe 'Concurrency' do
62
62
  expect(received1).to be(true)
63
63
  expect(received2).to be(true)
64
64
  end
65
+
66
+ it 'supports adding multiple #tap_into listeners' do
67
+ results = 10.times.map do |id|
68
+ Thread.new do
69
+ freddy1.tap_into "tap_into.listener.#{id}" do
70
+ end
71
+ end
72
+ end.map(&:join)
73
+
74
+ expect(results.count).to eq(10)
75
+ end
65
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urmas Talimaa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-01 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler