freddy 1.6.0 → 1.7.0

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
  SHA256:
3
- metadata.gz: c2c342119c1a4c330673258a8c5dbeb5d33ea15bc06ddbe261e1cfb8485829fe
4
- data.tar.gz: a66de9b5b4f97ff58e1f8a321daa5846526a68c41fb4d7e4121d0c90fed55101
3
+ metadata.gz: b7b2906e383a27fec45165c162d2a0a7a3a299dfdf390c599cf42288d75e5f3e
4
+ data.tar.gz: 882a6d64838f723c43c58189cd0b9786df758bdd357ea23dfcb2954c454fb92f
5
5
  SHA512:
6
- metadata.gz: fa9f61272f5f792c2e944ad39d2604693a14950d0a7bef43f3fcba8d3865ce0ff992877bc27427d66aa29314e1b6ae1fc6acde15e1f513169fbe49a1cc1c496a
7
- data.tar.gz: '0678e4121e3eaaa5669d5d5ef4963c91a31ace9f605ecaf1050136f98a3df1c3b6e24b6709e5abaed8b530c21f89695b18d6ed7c5ab7f6543e47e254abd01b18'
6
+ metadata.gz: b0d5031e6308383f5905f40ecc817945be9dd6df1f0abc6be662867d8d5b39b6c57ed0615d56d26d46ddcfe9dc05b4bc2d7a86b8f46d89d5ed118963b0c36063
7
+ data.tar.gz: 816406b89fb3fbac83fffd15b5d283755096675dc4f9095b041c585d950a47a11c46bb1ef1545747b08775c705531b7c383327d06bdba2175a96cb7bf6f3732b
@@ -1,10 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.1
4
- - jruby-9.1.5.0
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.
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  else
9
9
  'freddy'
10
10
  end
11
- spec.version = '1.6.0'
12
- spec.authors = ['Salemove TechMovers']
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'
@@ -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(pattern, options = {}, &callback)
133
- @logger.debug "Tapping into messages that match #{pattern}"
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
- pattern: pattern,
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:, pattern:, channel:, options:)
10
+ def initialize(thread_pool:, patterns:, channel:, options:)
11
11
  @consume_thread_pool = thread_pool
12
- @pattern = pattern
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
- if group
35
- @channel
36
- .queue("groups.#{group}", durable: durable?)
37
- .bind(topic_exchange, routing_key: @pattern)
38
- else
39
- @channel
40
- .queue('', exclusive: true)
41
- .bind(topic_exchange, routing_key: @pattern)
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.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
- - Salemove TechMovers
7
+ - Glia TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-15 00:00:00.000000000 Z
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
- rubyforge_project:
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