freddy 1.6.0 → 1.7.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/README.md +10 -0
- data/freddy.gemspec +2 -2
- data/lib/freddy.rb +3 -3
- data/lib/freddy/consumers/tap_into_consumer.rb +13 -10
- data/spec/integration/tap_into_with_group_spec.rb +15 -0
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7b2906e383a27fec45165c162d2a0a7a3a299dfdf390c599cf42288d75e5f3e
|
4
|
+
data.tar.gz: 882a6d64838f723c43c58189cd0b9786df758bdd357ea23dfcb2954c454fb92f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0d5031e6308383f5905f40ecc817945be9dd6df1f0abc6be662867d8d5b39b6c57ed0615d56d26d46ddcfe9dc05b4bc2d7a86b8f46d89d5ed118963b0c36063
|
7
|
+
data.tar.gz: 816406b89fb3fbac83fffd15b5d283755096675dc4f9095b041c585d950a47a11c46bb1ef1545747b08775c705531b7c383327d06bdba2175a96cb7bf6f3732b
|
data/.travis.yml
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- jruby-9.
|
3
|
+
- 2.5.6
|
4
|
+
- jruby-9.2.8.0
|
5
5
|
addons:
|
6
6
|
code_climate:
|
7
7
|
repo_token: 1f3842b985fdeff6a36168165d491ca5f444667e9381a85c899a61706a9dd285
|
8
|
+
apt:
|
9
|
+
packages:
|
10
|
+
- rabbitmq-server
|
8
11
|
services:
|
9
12
|
- rabbitmq
|
10
13
|
before_script:
|
data/README.md
CHANGED
@@ -121,6 +121,16 @@ freddy.tap_into "somebody.*.love"
|
|
121
121
|
|
122
122
|
receives messages that are delivered to `somebody.to.love` but doesn't receive messages delivered to `someboy.not.to.love`
|
123
123
|
|
124
|
+
It is also possible to tap using multiple patterns:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
freddy.tap_into(['user.created', 'user.deleted'], group: 'user-event') do
|
128
|
+
# This processes events from both user.created topic and user.deleted topic.
|
129
|
+
# It also groups them into one queue called 'user-event'. This ensures that
|
130
|
+
# only one listener within a group process a particular event.
|
131
|
+
end
|
132
|
+
```
|
133
|
+
|
124
134
|
## The ResponderHandler
|
125
135
|
|
126
136
|
When responding to a message or tapping the ResponderHandler is returned.
|
data/freddy.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
else
|
9
9
|
'freddy'
|
10
10
|
end
|
11
|
-
spec.version = '1.
|
12
|
-
spec.authors = ['
|
11
|
+
spec.version = '1.7.0'
|
12
|
+
spec.authors = ['Glia TechMovers']
|
13
13
|
spec.email = ['techmovers@salemove.com']
|
14
14
|
spec.description = 'Messaging API'
|
15
15
|
spec.summary = 'API for inter-application messaging supporting acknowledgements and request-response'
|
data/lib/freddy.rb
CHANGED
@@ -129,12 +129,12 @@ class Freddy
|
|
129
129
|
# freddy.tap_into 'notifications.*' do |message|
|
130
130
|
# puts "Notification showed #{message.inspect}"
|
131
131
|
# end
|
132
|
-
def tap_into(
|
133
|
-
@logger.debug "Tapping into messages that match #{
|
132
|
+
def tap_into(pattern_or_patterns, options = {}, &callback)
|
133
|
+
@logger.debug "Tapping into messages that match #{pattern_or_patterns}"
|
134
134
|
|
135
135
|
Consumers::TapIntoConsumer.consume(
|
136
136
|
thread_pool: Thread.pool(@prefetch_buffer_size),
|
137
|
-
|
137
|
+
patterns: Array(pattern_or_patterns),
|
138
138
|
channel: @connection.create_channel(prefetch: @prefetch_buffer_size),
|
139
139
|
options: options,
|
140
140
|
&callback
|
@@ -7,9 +7,9 @@ class Freddy
|
|
7
7
|
new(*attrs).consume(&block)
|
8
8
|
end
|
9
9
|
|
10
|
-
def initialize(thread_pool:,
|
10
|
+
def initialize(thread_pool:, patterns:, channel:, options:)
|
11
11
|
@consume_thread_pool = thread_pool
|
12
|
-
@
|
12
|
+
@patterns = patterns
|
13
13
|
@channel = channel
|
14
14
|
@options = options
|
15
15
|
|
@@ -31,15 +31,18 @@ class Freddy
|
|
31
31
|
def create_queue
|
32
32
|
topic_exchange = @channel.topic(Freddy::FREDDY_TOPIC_EXCHANGE_NAME)
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
.queue("groups.#{group}", durable: durable?)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
34
|
+
queue =
|
35
|
+
if group
|
36
|
+
@channel.queue("groups.#{group}", durable: durable?)
|
37
|
+
else
|
38
|
+
@channel.queue('', exclusive: true)
|
39
|
+
end
|
40
|
+
|
41
|
+
@patterns.each do |pattern|
|
42
|
+
queue.bind(topic_exchange, routing_key: pattern)
|
42
43
|
end
|
44
|
+
|
45
|
+
queue
|
43
46
|
end
|
44
47
|
|
45
48
|
def process_message(_queue, delivery)
|
@@ -40,4 +40,19 @@ describe 'Tapping into with group identifier' do
|
|
40
40
|
wait_for { counter == 2 }
|
41
41
|
expect(counter).to eq(2)
|
42
42
|
end
|
43
|
+
|
44
|
+
it 'taps into multiple topics' do
|
45
|
+
destination2 = random_destination
|
46
|
+
counter = 0
|
47
|
+
|
48
|
+
responder1.tap_into([destination, destination2], group: arbitrary_id) do
|
49
|
+
counter += 1
|
50
|
+
end
|
51
|
+
|
52
|
+
deliverer.deliver(destination, {})
|
53
|
+
deliverer.deliver(destination2, {})
|
54
|
+
|
55
|
+
wait_for { counter == 2 }
|
56
|
+
expect(counter).to eq(2)
|
57
|
+
end
|
43
58
|
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: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Glia TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -168,8 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
|
172
|
-
rubygems_version: 2.7.6
|
171
|
+
rubygems_version: 3.0.6
|
173
172
|
signing_key:
|
174
173
|
specification_version: 4
|
175
174
|
summary: API for inter-application messaging supporting acknowledgements and request-response
|