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 +4 -4
- data/freddy.gemspec +1 -1
- data/lib/freddy/consumers/tap_into_consumer.rb +12 -2
- data/spec/integration/concurrency_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a41652a44eeac100da5b263e45cacf1d4d18bac
|
4
|
+
data.tar.gz: 42e617e90df278bb931646a89281fde4e155be51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 006202ca3ddeb5670e824319dad63e1e980bc733a8a4a667f8a5faa1544a5f0af6c828515bc8ceb3f38fdf9f8f332fd3c09e4d6a8feb07522bf0dc256bd12253
|
7
|
+
data.tar.gz: 7f0d305730a3a7824302c87bfc95845f75e68f646b6554d73edcc1484752a9431f4095be73b54292c85a7c06f2e266c77e743830e9877ba8aa89e3de30886244
|
data/freddy.gemspec
CHANGED
@@ -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 =
|
12
|
-
|
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.
|
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-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|