active_publisher 1.2.0.pre6 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 37f2dab5370f3b41d1b6e0c6d31f2da54f40528c
4
- data.tar.gz: dc04b0a100a216a194ef30f5bb07c1fb27f17982
2
+ SHA256:
3
+ metadata.gz: 7d07df691c4875cf4b99d301fc9cc3113a83b8ecaf888b6d2b6320b887c74f2d
4
+ data.tar.gz: 5b15565ea6e5d191bd251d527bf5f32377ec27e6642453b9fee3942538edca2e
5
5
  SHA512:
6
- metadata.gz: f2f5c82a0923940966d5ce4d66e8448f129246b9dd54481313164ceb6c82231fad94522ee5dfbbe4e307d643aff7d8f7e06570343f44cdee22ac452962b6bd29
7
- data.tar.gz: 1ee748a6f8e1a145d2b395598d25385e347f61310523928c8776df1ac9aa8187a11dd2dd7c5bf0d645e8908282dc304fa4a5f9825320488f31045bfdbddac0a5
6
+ metadata.gz: 7517b881037d04cb66effd45d49e16b39adbbdd76dbc0568d49440e9fd6e0ba8c960c5abd0b0c8df38209efe3c40d751a92e4b469746e764ebf04c5be01de58d
7
+ data.tar.gz: fd049283784c2a6eca92fdf7ab008364edf1c4e691b7a2f8adf2a724a4478576c91c5375633f6253fb16f9e7c84e379ff5b6fdb8d02caf4ff8227252d1168df2
@@ -1,8 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3
4
- - 2.4
3
+ - 2.3.8
4
+ - 2.5.7
5
5
  - jruby-9.1.12.0
6
+ - jruby-9.2.7.0
7
+ addons:
8
+ apt:
9
+ packages:
10
+ - rabbitmq-server
6
11
  services:
7
12
  - rabbitmq
8
13
  sudo: false
@@ -35,6 +35,6 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "connection_pool"
36
36
  spec.add_development_dependency "fakeredis"
37
37
  spec.add_development_dependency "pry"
38
- spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "rake"
39
39
  spec.add_development_dependency "rspec", "~> 3.2"
40
40
  end
@@ -35,7 +35,7 @@ module ActivePublisher
35
35
  # @param [Hash] options hash to set message parameters (e.g. headers)
36
36
  def self.publish(route, payload, exchange_name, options = {})
37
37
  with_exchange(exchange_name) do |exchange|
38
- ::ActiveSupport::Notifications.instrument "message_published.active_publisher" do
38
+ ::ActiveSupport::Notifications.instrument "message_published.active_publisher", :route => route do
39
39
  exchange.publish(payload, publishing_options(route, options))
40
40
  end
41
41
  end
@@ -51,7 +51,7 @@ module ActivePublisher
51
51
  fail ActivePublisher::ExchangeMismatchError, "bulk publish messages must match publish_all exchange_name" if message.exchange_name != exchange_name
52
52
 
53
53
  begin
54
- ::ActiveSupport::Notifications.instrument "message_published.active_publisher" do
54
+ ::ActiveSupport::Notifications.instrument "message_published.active_publisher", :route => message.route do
55
55
  exchange.publish(message.payload, publishing_options(message.route, message.options || {}))
56
56
  end
57
57
  rescue
@@ -108,16 +108,15 @@ module ActivePublisher
108
108
  end
109
109
 
110
110
  def publish_all(channel, exchange_name, messages)
111
- ::ActiveSupport::Notifications.instrument "message_published.active_publisher", :message_count => messages.size do
112
- exchange = channel.topic(exchange_name)
113
- messages.each do |message|
114
- fail ActivePublisher::ExchangeMismatchError, "bulk publish messages must match publish_all exchange_name" if message.exchange_name != exchange_name
115
-
111
+ exchange = channel.topic(exchange_name)
112
+ messages.each do |message|
113
+ fail ::ActivePublisher::ExchangeMismatchError, "bulk publish messages must match publish_all exchange_name" if message.exchange_name != exchange_name
114
+ ::ActiveSupport::Notifications.instrument "message_published.active_publisher", :route => message.route, :message_count => 1 do
116
115
  options = ::ActivePublisher.publishing_options(message.route, message.options || {})
117
116
  exchange.publish(message.payload, options)
118
117
  end
119
- wait_for_confirms(channel)
120
118
  end
119
+ wait_for_confirms(channel)
121
120
  end
122
121
 
123
122
  def wait_for_confirms(channel)
@@ -85,6 +85,7 @@ module ActivePublisher
85
85
 
86
86
  messages = multi_response.first
87
87
  success = multi_response.last
88
+ return [] if multi_response.size != 2 || success.nil?
88
89
  return [] unless success =~ /ok/i
89
90
 
90
91
  messages = [] if messages.nil?
@@ -63,8 +63,8 @@ module ActivePublisher
63
63
 
64
64
  yaml_config = attempt_to_load_yaml_file(env)
65
65
  DEFAULTS.each_pair do |key, value|
66
- setting = cli_options[key] || cli_options[key.to_s] || yaml_config[key] || yaml_config[key.to_s]
67
- ::ActivePublisher.configuration.public_send("#{key}=", setting) if setting
66
+ exists, setting = fetch_config_value(key, cli_options, yaml_config)
67
+ ::ActivePublisher.configuration.public_send("#{key}=", setting) if exists
68
68
  end
69
69
 
70
70
  true
@@ -88,6 +88,15 @@ module ActivePublisher
88
88
  end
89
89
  private_class_method :attempt_to_load_yaml_file
90
90
 
91
+ def self.fetch_config_value(key, cli_options, yaml_config)
92
+ return [true, cli_options[key]] if cli_options.key?(key)
93
+ return [true, cli_options[key.to_s]] if cli_options.key?(key.to_s)
94
+ return [true, yaml_config[key]] if yaml_config.key?(key)
95
+ return [true, yaml_config[key.to_s]] if yaml_config.key?(key.to_s)
96
+ [false, nil]
97
+ end
98
+ private_class_method :fetch_config_value
99
+
91
100
  ##
92
101
  # Instance Methods
93
102
  #
@@ -31,9 +31,22 @@ module ActivePublisher
31
31
  def self.create_connection
32
32
  if ::RUBY_PLATFORM == "java"
33
33
  connection = ::MarchHare.connect(connection_options)
34
+ connection.on_blocked do |reason|
35
+ on_blocked(reason)
36
+ end
37
+ connection.on_unblocked do
38
+ on_unblocked
39
+ end
40
+ connection
34
41
  else
35
42
  connection = ::Bunny.new(connection_options)
36
43
  connection.start
44
+ connection.on_blocked do |blocked_message|
45
+ on_blocked(blocked_message.reason)
46
+ end
47
+ connection.on_unblocked do
48
+ on_unblocked
49
+ end
37
50
  connection
38
51
  end
39
52
  end
@@ -58,5 +71,15 @@ module ActivePublisher
58
71
  }
59
72
  end
60
73
  private_class_method :connection_options
74
+
75
+ def self.on_blocked(reason)
76
+ ::ActiveSupport::Notifications.instrument("connection_blocked.active_publisher", :reason => reason)
77
+ end
78
+ private_class_method :on_blocked
79
+
80
+ def self.on_unblocked
81
+ ::ActiveSupport::Notifications.instrument("connection_unblocked.active_publisher")
82
+ end
83
+ private_class_method :on_unblocked
61
84
  end
62
85
  end
@@ -1,3 +1,3 @@
1
1
  module ActivePublisher
2
- VERSION = "1.2.0.pre6"
2
+ VERSION = "1.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.pre6
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Stien
@@ -9,10 +9,10 @@ authors:
9
9
  - Brandon Dewitt
10
10
  - Devin Christensen
11
11
  - Michael Ries
12
- autorequire:
12
+ autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2018-01-24 00:00:00.000000000 Z
15
+ date: 2020-07-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bunny
@@ -144,16 +144,16 @@ dependencies:
144
144
  name: rake
145
145
  requirement: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - "~>"
147
+ - - ">="
148
148
  - !ruby/object:Gem::Version
149
- version: '10.0'
149
+ version: '0'
150
150
  type: :development
151
151
  prerelease: false
152
152
  version_requirements: !ruby/object:Gem::Requirement
153
153
  requirements:
154
- - - "~>"
154
+ - - ">="
155
155
  - !ruby/object:Gem::Version
156
- version: '10.0'
156
+ version: '0'
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rspec
159
159
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ homepage: https://github.com/mxenabled/active_publisher
208
208
  licenses:
209
209
  - MIT
210
210
  metadata: {}
211
- post_install_message:
211
+ post_install_message:
212
212
  rdoc_options: []
213
213
  require_paths:
214
214
  - lib
@@ -219,13 +219,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
219
  version: '0'
220
220
  required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  requirements:
222
- - - ">"
222
+ - - ">="
223
223
  - !ruby/object:Gem::Version
224
- version: 1.3.1
224
+ version: '0'
225
225
  requirements: []
226
- rubyforge_project:
227
- rubygems_version: 2.6.13
228
- signing_key:
226
+ rubygems_version: 3.1.2
227
+ signing_key:
229
228
  specification_version: 4
230
229
  summary: Aims to make publishing work across MRI and jRuby painless and add some nice
231
230
  features like automatially publishing lifecycle events for ActiveRecord models.