multiple_man 0.5.13 → 0.5.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multiple_man/connection.rb +5 -20
- data/lib/multiple_man/listener.rb +3 -1
- data/lib/multiple_man/model_populator.rb +2 -0
- data/lib/multiple_man/subscribers/base.rb +4 -4
- data/lib/multiple_man/subscribers/model_subscriber.rb +10 -1
- data/lib/multiple_man/version.rb +1 -1
- data/spec/connection_spec.rb +1 -1
- 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: 7f336d9d6a65f813a1bbe25be73d2ed94600f6a3
|
4
|
+
data.tar.gz: 0aa6701beb28ec20efb7422876dee79b8277f8a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b83d9ca1083970a7751b41836dfb06168a2b8e0228f801e8e94c9bc95e91f4840c40b8127a24110e3b17295cf496a1279032abedc7f57c30e36b36d6b1928d33
|
7
|
+
data.tar.gz: b94651a2419c3263732b1b75241b1b31a48f494b31c19deec9e59f1e678e8ab709d4d79c93e9c88b334e49eb7e368e0f94a38fbe7f550f3ac78d51cccad45187
|
@@ -4,31 +4,16 @@ require 'active_support/core_ext/module'
|
|
4
4
|
|
5
5
|
module MultipleMan
|
6
6
|
class Connection
|
7
|
-
@mutex = Mutex.new
|
8
|
-
|
9
|
-
def self.connection
|
10
|
-
@mutex.synchronize do
|
11
|
-
# If the server has closed our connection, re-initialize
|
12
|
-
@connection = nil if @connection && @connection.closed?
|
13
|
-
|
14
|
-
@connection ||= begin
|
15
|
-
connection = Bunny.new(MultipleMan.configuration.connection)
|
16
|
-
MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}"
|
17
|
-
connection.start
|
18
|
-
connection
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
7
|
|
23
8
|
def self.connect
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
9
|
+
connection = Bunny.new(MultipleMan.configuration.connection)
|
10
|
+
MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}"
|
11
|
+
connection.start
|
12
|
+
channel = connection.create_channel
|
29
13
|
yield new(channel) if block_given?
|
30
14
|
ensure
|
31
15
|
channel.close if channel && channel.open?
|
16
|
+
connection.close if connection && connection.open?
|
32
17
|
end
|
33
18
|
|
34
19
|
attr_reader :topic
|
@@ -23,7 +23,9 @@ module MultipleMan
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def init_connection
|
26
|
-
|
26
|
+
connection = Bunny.new(MultipleMan.configuration.connection)
|
27
|
+
connection.start
|
28
|
+
channel = connection.create_channel(nil, MultipleMan.configuration.worker_concurrency)
|
27
29
|
channel.prefetch(100)
|
28
30
|
self.connection = MultipleMan::Connection.new(channel)
|
29
31
|
end
|
@@ -7,19 +7,19 @@ module MultipleMan::Subscribers
|
|
7
7
|
|
8
8
|
attr_reader :klass
|
9
9
|
|
10
|
-
def create
|
10
|
+
def create(payload)
|
11
11
|
# noop
|
12
12
|
end
|
13
13
|
|
14
|
-
def update
|
14
|
+
def update(payload)
|
15
15
|
# noop
|
16
16
|
end
|
17
17
|
|
18
|
-
def destroy
|
18
|
+
def destroy(payload)
|
19
19
|
# noop
|
20
20
|
end
|
21
21
|
|
22
|
-
def seed
|
22
|
+
def seed(payload)
|
23
23
|
# noop
|
24
24
|
end
|
25
25
|
|
@@ -30,7 +30,16 @@ module MultipleMan::Subscribers
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def find_conditions(id)
|
33
|
-
id.kind_of?(Hash) ? id : {multiple_man_identifier: id}
|
33
|
+
id.kind_of?(Hash) ? cleanse_id(id) : {multiple_man_identifier: id}
|
34
|
+
end
|
35
|
+
|
36
|
+
def cleanse_id(hash)
|
37
|
+
if hash.keys.length > 1 && hash.keys.include?("id")
|
38
|
+
id = hash.delete("id")
|
39
|
+
hash.merge("source_id" => id)
|
40
|
+
else
|
41
|
+
hash
|
42
|
+
end
|
34
43
|
end
|
35
44
|
|
36
45
|
attr_writer :klass
|
data/lib/multiple_man/version.rb
CHANGED
data/spec/connection_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe MultipleMan::Connection do
|
4
4
|
|
5
|
-
let(:mock_bunny) { double(Bunny) }
|
5
|
+
let(:mock_bunny) { double(Bunny, open?: true, close: nil) }
|
6
6
|
let(:mock_channel) { double(Bunny::Channel, close: nil, open?: true, topic: nil) }
|
7
7
|
|
8
8
|
describe "connect" do
|
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: 0.5.
|
4
|
+
version: 0.5.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brunner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|