multiple_man 1.6.0 → 1.6.1
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/lib/multiple_man/runner.rb +18 -1
- data/lib/multiple_man/version.rb +1 -1
- data/spec/runner_spec.rb +24 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34c76ed50d75d8813d5bfb120ed9b18bdaccaec1
|
4
|
+
data.tar.gz: 29ce2ff4cd58a046a7f5a4dae146ae73412e4030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6e04e9f08b36cff2353c38d065a206169536852b409b70091dd2054bf40e1d198da9a8f8aa4525569570562a551164fcde4ad109da23db6e577c83f0ae01ad
|
7
|
+
data.tar.gz: 9792ce4da51bc92d5e3f65d803d4bce5e0abb1061bf6cf96104a2a3fc119ec7718def7eb853e542299fddc475e5c6eb1c678b6e64b7d4b2dcd687d043b824a18
|
data/lib/multiple_man/runner.rb
CHANGED
@@ -13,6 +13,7 @@ module MultipleMan
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def run
|
16
|
+
trap_signals!
|
16
17
|
preload_framework!
|
17
18
|
channel.prefetch(prefetch_size)
|
18
19
|
build_listener.listen
|
@@ -24,6 +25,18 @@ module MultipleMan
|
|
24
25
|
|
25
26
|
def_delegators :config, :prefetch_size, :queue_name, :listeners, :topic_name
|
26
27
|
|
28
|
+
def trap_signals!
|
29
|
+
handler = proc do |signal|
|
30
|
+
puts "received #{Signal.signame(signal)}"
|
31
|
+
channel.close
|
32
|
+
connection.close
|
33
|
+
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
%w(INT QUIT TERM).each { |signal| Signal.trap(signal, handler) }
|
38
|
+
end
|
39
|
+
|
27
40
|
def preload_framework!
|
28
41
|
Rails.application.eager_load! if defined?(Rails)
|
29
42
|
if defined?(Hanami)
|
@@ -61,7 +74,11 @@ module MultipleMan
|
|
61
74
|
end
|
62
75
|
|
63
76
|
def channel
|
64
|
-
@channel ||=
|
77
|
+
@channel ||= connection.create_channel
|
78
|
+
end
|
79
|
+
|
80
|
+
def connection
|
81
|
+
Connection.connection
|
65
82
|
end
|
66
83
|
|
67
84
|
def config
|
data/lib/multiple_man/version.rb
CHANGED
data/spec/runner_spec.rb
CHANGED
@@ -8,10 +8,33 @@ describe MultipleMan::Runner do
|
|
8
8
|
it 'boots app and listens on new channel' do
|
9
9
|
expect(MultipleMan::Connection).to receive(:connection).and_return(mock_connection)
|
10
10
|
expect(MultipleMan::Consumers::General).to receive(:new).and_return(mock_consumer)
|
11
|
-
|
12
11
|
expect(mock_consumer).to receive(:listen)
|
13
12
|
|
14
13
|
runner = described_class.new(mode: :general)
|
15
14
|
runner.run
|
16
15
|
end
|
16
|
+
|
17
|
+
context "shutdown" do
|
18
|
+
let(:mock_consumer) { double("Consumer", listen: ->(_){ sleep(1); raise "no interrupt!" }) }
|
19
|
+
|
20
|
+
xit 'closes connections and exits gracefully' do
|
21
|
+
ps = fork do
|
22
|
+
expect(MultipleMan::Connection).to receive(:connection).and_return(mock_connection)
|
23
|
+
expect(MultipleMan::Consumers::General).to receive(:new).and_return(mock_consumer)
|
24
|
+
|
25
|
+
expect(mock_channel).to receive(:close)
|
26
|
+
expect(mock_connection).to receive(:close)
|
27
|
+
|
28
|
+
described_class.new(mode: :general).run
|
29
|
+
end
|
30
|
+
|
31
|
+
sleep 0.01
|
32
|
+
|
33
|
+
Process.kill('INT', ps)
|
34
|
+
a, status = Process.waitpid2(ps)
|
35
|
+
# binding.pry
|
36
|
+
|
37
|
+
expect(status.success?).to be true
|
38
|
+
end
|
39
|
+
end
|
17
40
|
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.6.
|
4
|
+
version: 1.6.1
|
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-
|
11
|
+
date: 2017-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
178
|
version: '0'
|
179
179
|
requirements: []
|
180
180
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.6.12
|
182
182
|
signing_key:
|
183
183
|
specification_version: 4
|
184
184
|
summary: MultipleMan syncs changes to ActiveRecord models via AMQP
|