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 +5 -5
- data/.travis.yml +7 -2
- data/active_publisher.gemspec +1 -1
- data/lib/active_publisher.rb +2 -2
- data/lib/active_publisher/async/in_memory_adapter/consumer_thread.rb +5 -6
- data/lib/active_publisher/async/redis_adapter/redis_multi_pop_queue.rb +1 -0
- data/lib/active_publisher/configuration.rb +11 -2
- data/lib/active_publisher/connection.rb +23 -0
- data/lib/active_publisher/version.rb +1 -1
- metadata +12 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d07df691c4875cf4b99d301fc9cc3113a83b8ecaf888b6d2b6320b887c74f2d
|
4
|
+
data.tar.gz: 5b15565ea6e5d191bd251d527bf5f32377ec27e6642453b9fee3942538edca2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7517b881037d04cb66effd45d49e16b39adbbdd76dbc0568d49440e9fd6e0ba8c960c5abd0b0c8df38209efe3c40d751a92e4b469746e764ebf04c5be01de58d
|
7
|
+
data.tar.gz: fd049283784c2a6eca92fdf7ab008364edf1c4e691b7a2f8adf2a724a4478576c91c5375633f6253fb16f9e7c84e379ff5b6fdb8d02caf4ff8227252d1168df2
|
data/.travis.yml
CHANGED
data/active_publisher.gemspec
CHANGED
@@ -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"
|
38
|
+
spec.add_development_dependency "rake"
|
39
39
|
spec.add_development_dependency "rspec", "~> 3.2"
|
40
40
|
end
|
data/lib/active_publisher.rb
CHANGED
@@ -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
|
-
|
112
|
-
|
113
|
-
messages.
|
114
|
-
|
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)
|
@@ -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 =
|
67
|
-
::ActivePublisher.configuration.public_send("#{key}=", setting) if
|
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
|
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.
|
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:
|
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: '
|
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: '
|
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:
|
224
|
+
version: '0'
|
225
225
|
requirements: []
|
226
|
-
|
227
|
-
|
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.
|