multiple_man 0.5.10 → 0.5.11
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e67a4986fcfa2f58d6e05f8b00948c36380545e8
|
4
|
+
data.tar.gz: 2d0c3ed94090f760a86f94fd0972fc9b21fbf7af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b72667abc2681f98488a3c6acc3ec8647d81330c20c812304c03e7ba949179a3b41cb6c194f0467aa9073fc32246c9af0ef659566dd515f9f9d9db70f8f1cc2e
|
7
|
+
data.tar.gz: fbc00833e9173673a322465d1c635ca5d56763d7766be5fef8120421f3f7a47a5da38a4d229b81b1755aac7c8a5bc933172b55b785045b14e61a24227150a59d
|
@@ -8,6 +8,9 @@ module MultipleMan
|
|
8
8
|
|
9
9
|
def self.connection
|
10
10
|
@mutex.synchronize do
|
11
|
+
# If the server has closed our connection, re-initialize
|
12
|
+
@connection = nil if @connection && @connection.closed?
|
13
|
+
|
11
14
|
@connection ||= begin
|
12
15
|
connection = Bunny.new(MultipleMan.configuration.connection)
|
13
16
|
MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}"
|
@@ -18,18 +21,12 @@ module MultipleMan
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def self.connect
|
21
|
-
reconnect unless connection.open?
|
22
|
-
|
23
24
|
channel = connection.create_channel
|
24
25
|
yield new(channel) if block_given?
|
25
26
|
ensure
|
26
27
|
channel.close if channel
|
27
28
|
end
|
28
29
|
|
29
|
-
def self.reconnect
|
30
|
-
connection.start
|
31
|
-
end
|
32
|
-
|
33
30
|
attr_reader :topic
|
34
31
|
|
35
32
|
def initialize(channel)
|
@@ -3,14 +3,6 @@ require 'active_support/core_ext'
|
|
3
3
|
module MultipleMan
|
4
4
|
class ModelPublisher
|
5
5
|
|
6
|
-
def self.build(options = {})
|
7
|
-
if options[:async] == true
|
8
|
-
AsyncModelPublisher.new(options)
|
9
|
-
else
|
10
|
-
new(options)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
6
|
def initialize(options = {})
|
15
7
|
self.options = options.with_indifferent_access
|
16
8
|
end
|
data/lib/multiple_man/version.rb
CHANGED
data/lib/multiple_man.rb
CHANGED
@@ -10,7 +10,6 @@ module MultipleMan
|
|
10
10
|
require 'multiple_man/subscribers/registry'
|
11
11
|
require 'multiple_man/configuration'
|
12
12
|
require 'multiple_man/model_publisher'
|
13
|
-
require 'multiple_man/async_model_publisher'
|
14
13
|
require 'multiple_man/attribute_extractor'
|
15
14
|
require 'multiple_man/connection'
|
16
15
|
require 'multiple_man/routing_key'
|
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.11
|
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-09-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,7 +108,6 @@ files:
|
|
108
108
|
- README.md
|
109
109
|
- Rakefile
|
110
110
|
- lib/multiple_man.rb
|
111
|
-
- lib/multiple_man/async_model_publisher.rb
|
112
111
|
- lib/multiple_man/attribute_extractor.rb
|
113
112
|
- lib/multiple_man/configuration.rb
|
114
113
|
- lib/multiple_man/connection.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module MultipleMan
|
2
|
-
class AsyncModelPublisher < ModelPublisher
|
3
|
-
|
4
|
-
def publish(records, operation=:create)
|
5
|
-
return unless MultipleMan.configuration.enabled
|
6
|
-
|
7
|
-
if records.respond_to?(:pluck)
|
8
|
-
return unless records.any?
|
9
|
-
ids = records.pluck(:id)
|
10
|
-
klass = records.first.class.name
|
11
|
-
else
|
12
|
-
return if records.nil?
|
13
|
-
ids = [records.id]
|
14
|
-
klass = records.class.name
|
15
|
-
end
|
16
|
-
|
17
|
-
ModelPublisherJob.perform_async(klass, ids, options, operation)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
class ModelPublisherJob
|
23
|
-
include Sidekiq::Worker
|
24
|
-
|
25
|
-
def perform(record_type, ids, options, operation)
|
26
|
-
records = Kernel.const_get(record_type).where(id: ids)
|
27
|
-
ModelPublisher.new(options).publish(records, operation)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|