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: 55f92c313a41df73f660aeb11219df30699b05d2
4
- data.tar.gz: 363a8538cf04a8dc30a3092a6ce83cb4f9c81ab4
3
+ metadata.gz: e67a4986fcfa2f58d6e05f8b00948c36380545e8
4
+ data.tar.gz: 2d0c3ed94090f760a86f94fd0972fc9b21fbf7af
5
5
  SHA512:
6
- metadata.gz: b9255e20caedf780c92afc54c206b0bafed00b49dc0e6ba0e4646946344ba80356127e56b91bc911f1eb9f0511a08597b9d64972ccac610aa5d1354028b02b8d
7
- data.tar.gz: d3aef199d466696ff5978d7057a4c86b799c6dbc8f2f5384068f5daccea2dc252831c8e213eacf774f85e75f1150d761323a90fbefc9cfa6b7fa937af339a467
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)
@@ -22,7 +22,7 @@ module MultipleMan
22
22
  end
23
23
 
24
24
  def publish(options = {})
25
- self.multiple_man_publisher = ModelPublisher.build(options)
25
+ self.multiple_man_publisher = ModelPublisher.new(options)
26
26
  end
27
27
  end
28
28
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MultipleMan
2
- VERSION = "0.5.10"
2
+ VERSION = "0.5.11"
3
3
  end
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.10
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-23 00:00:00.000000000 Z
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