multiple_man 1.4.0 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 546b5d63fbc985f621b1b5c891aa7cdbc93bab8b
4
- data.tar.gz: 0201b5a619231469deb7dc5213be502dda2c0fe8
3
+ metadata.gz: 8b0b5340cba015cfbf0a2a43f04283743415bf2f
4
+ data.tar.gz: 541a5bc2ba571cc2d915508b6ba12e70c58a9e14
5
5
  SHA512:
6
- metadata.gz: 175d5be3b1a35cc18447d0be840d6a7615f5992f62650d62a054eed9288201629bf6646b8e257fc5bcd1549cf2ddc19cba7a17accb7d9b283679358e301b1bae
7
- data.tar.gz: 230e1bedf174de89182ab379e4e1ec93b1f1d8863bd42b214dbd43d23001337d815a03b0276bd97a3220beb12c570cb8bead859d2a1a4361e335579cc4625d1f
6
+ metadata.gz: 3ef57043bd9b127e7418b5f6935ed3589d71919f1a740b4d658a0d04e9025af6d73fb467a5414d6b44cd8a2340f1ff2efe18de6ecf25fa63731506c21dcdfe63
7
+ data.tar.gz: 192d47727ed9dd2b881351d9eac3eb2c0fcc66e145ef56f9dcbb07f7b71cbb4257a25e7afbc2a9ac6ebf240424d4c142e3a740877cd0e62bb3aea7da874c81bd
data/README.md CHANGED
@@ -195,26 +195,6 @@ MyModel.multiple_man_publish(:seed)
195
195
 
196
196
  3. Stop the seeder rake task when all of your messages have been processed. You can check your RabbitMQ server
197
197
 
198
- ## Upgrading to 1.0
199
-
200
- The major change is that MultipleMan will no longer create a queue per listener.
201
- There is only 1 queue that will have multiple bindings to the exchange so that
202
- you have a chance to maintain causal consistency.
203
-
204
- Assuming you are using vanilla MultipleMan you will need to run both the
205
- regular worker and the new 'transition_worker' for a short period. The
206
- transitional worker will connect to your old queues, unbind them and allow them
207
- to drain. Once the queues are empty you can safely shut the transitional worker
208
- down and delete the old queues.
209
-
210
- So for example if you use a Procfile:
211
-
212
- ```
213
- multiple_man_worker: rake multiple_man:worker
214
- # Temporary until old queues are drained
215
- transition_worker: rake multiple_man:transition_worker
216
- ```
217
-
218
198
  ## Contributing
219
199
 
220
200
  1. Fork it
@@ -14,7 +14,7 @@ module MultipleMan
14
14
  MultipleMan.logger.debug "Starting listeners."
15
15
  create_bindings
16
16
 
17
- queue.subscribe(manual_ack: true) do |delivery_info, meta_data, payload|
17
+ queue.subscribe(block: true, manual_ack: true) do |delivery_info, meta_data, payload|
18
18
  MultipleMan.logger.debug "Processing message for #{delivery_info.routing_key}."
19
19
  message = JSON.parse(payload).with_indifferent_access
20
20
  receive(delivery_info, meta_data, message)
@@ -1,19 +1,6 @@
1
1
  require 'forwardable'
2
2
 
3
3
  module MultipleMan
4
- def self.trap_signals!
5
- return if @signals_trapped
6
-
7
- @signals_trapped = true
8
-
9
- handler = proc do |signal|
10
- puts "received #{Signal.signame(signal)}"
11
- exit
12
- end
13
-
14
- %w(INT QUIT TERM).each { |signal| Signal.trap(signal, handler) }
15
- end
16
-
17
4
  class Runner
18
5
  extend Forwardable
19
6
 
@@ -26,11 +13,9 @@ module MultipleMan
26
13
  end
27
14
 
28
15
  def run
29
- MultipleMan.trap_signals!
30
16
  preload_framework!
31
17
  channel.prefetch(prefetch_size)
32
18
  build_listener.listen
33
- sleep
34
19
  end
35
20
 
36
21
  private
@@ -8,29 +8,4 @@ namespace :multiple_man do
8
8
  task seed: :environment do
9
9
  MultipleMan::Runner.new(mode: :seed).run
10
10
  end
11
-
12
- desc 'Run transitional worker'
13
- task transition_worker: :environment do
14
- Rails.application.eager_load! if defined?(Rails)
15
-
16
- topic = MultipleMan.configuration.topic_name
17
- app_name = MultipleMan.configuration.app_name
18
- channel = MultipleMan::Connection.connection.create_channel
19
- channel.prefetch(MultipleMan.configuration.prefetch_size)
20
-
21
- MultipleMan.configuration.listeners.each do |listener|
22
- queue_name = listener.respond_to?(:queue_name) ?
23
- listener.queue_name :
24
- "#{topic}.#{app_name}.#{listener.listen_to}"
25
-
26
- next unless MultipleMan::Connection.connection.queue_exists?(queue_name)
27
- queue = channel.queue(queue_name, durable: true, auto_delete: false)
28
-
29
- MultipleMan::Consumers::Transitional.new(subscription: listener, queue: queue, topic: topic).listen
30
- end
31
-
32
- MultipleMan.trap_signals!
33
- sleep
34
- end
35
-
36
11
  end
@@ -1,3 +1,3 @@
1
1
  module MultipleMan
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -29,7 +29,7 @@ describe MultipleMan::Consumers::General do
29
29
 
30
30
  expect(queue).to receive(:bind).with('some-topic', routing_key: subscriptions.first.routing_key).ordered
31
31
  expect(queue).to receive(:bind).with('some-topic', routing_key: subscriptions.last.routing_key).ordered
32
- expect(queue).to receive(:subscribe).with(manual_ack: true).ordered
32
+ expect(queue).to receive(:subscribe).with(block: true, manual_ack: true).ordered
33
33
 
34
34
  subject = described_class.new(subscribers: subscriptions, queue: queue, topic: 'some-topic')
35
35
 
@@ -17,7 +17,7 @@ describe MultipleMan::Consumers::Seed do
17
17
  queue = double(Bunny::Queue, channel: channel)
18
18
 
19
19
  expect(queue).to receive(:bind).with('some-topic', routing_key: "multiple_man.seed.SomeClass")
20
- expect(queue).to receive(:subscribe).with(manual_ack: true)
20
+ expect(queue).to receive(:subscribe).with(block: true, manual_ack: true)
21
21
 
22
22
  subject = described_class.new(subscribers: [listener1.new], queue: queue, topic: 'some-topic')
23
23
  subject.listen
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe MultipleMan::Runner do
4
+ let(:mock_channel) { double("Channel", prefetch: true, queue: true) }
5
+ let(:mock_connection) { double("Connection", create_channel: mock_channel) }
6
+ let(:mock_consumer) { double("Consumer", listen: true) }
7
+
8
+ it 'boots app and listens on new channel' do
9
+ expect(MultipleMan::Connection).to receive(:connection).and_return(mock_connection)
10
+ expect(MultipleMan::Consumers::General).to receive(:new).and_return(mock_consumer)
11
+
12
+ expect(mock_consumer).to receive(:listen)
13
+
14
+ runner = described_class.new(mode: :general)
15
+ runner.run
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiple_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-07 00:00:00.000000000 Z
11
+ date: 2017-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -153,6 +153,7 @@ files:
153
153
  - spec/model_publisher_spec.rb
154
154
  - spec/payload_generator_spec.rb
155
155
  - spec/routing_key_spec.rb
156
+ - spec/runner_spec.rb
156
157
  - spec/spec_helper.rb
157
158
  - spec/subscribers/base_spec.rb
158
159
  - spec/subscribers/model_subscriber_spec.rb
@@ -198,6 +199,7 @@ test_files:
198
199
  - spec/model_publisher_spec.rb
199
200
  - spec/payload_generator_spec.rb
200
201
  - spec/routing_key_spec.rb
202
+ - spec/runner_spec.rb
201
203
  - spec/spec_helper.rb
202
204
  - spec/subscribers/base_spec.rb
203
205
  - spec/subscribers/model_subscriber_spec.rb