action_subscriber 2.1.0.pre1-java → 2.1.1-java
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 +4 -4
- data/lib/action_subscriber.rb +14 -4
- data/lib/action_subscriber/configuration.rb +15 -2
- data/lib/action_subscriber/rabbit_connection.rb +4 -1
- data/lib/action_subscriber/uri.rb +28 -0
- data/lib/action_subscriber/version.rb +1 -1
- data/spec/integration/inferred_routes_spec.rb +7 -0
- data/spec/lib/action_subscriber/configuration_spec.rb +12 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bb53b1d4649ffe66409823cf35a69ffc3c2f773
|
4
|
+
data.tar.gz: 807b0206c26e9033012b6872e3291db06820d26d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fa2f6df1b924d98b696bea64acfbfb592dee42abfe5a17cfe2012e30ae619aeee8fce1d1d43a59d11c015f8f7153010aa5800a9219e2cb1067a47a3db6171e0
|
7
|
+
data.tar.gz: a92dc35e85dc2e7bceef7d01ee9b0a463659f8360a773df06556c28078e28d6ed671f91991dc4e365fe0e6c712ddfbff06af7ec6786e4c89c7d11ebdfbc2bf3a
|
data/lib/action_subscriber.rb
CHANGED
@@ -29,6 +29,7 @@ require "action_subscriber/route_set"
|
|
29
29
|
require "action_subscriber/router"
|
30
30
|
require "action_subscriber/threadpool"
|
31
31
|
require "action_subscriber/base"
|
32
|
+
require "action_subscriber/uri"
|
32
33
|
|
33
34
|
module ActionSubscriber
|
34
35
|
##
|
@@ -59,8 +60,12 @@ module ActionSubscriber
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def self.draw_routes(&block)
|
62
|
-
|
63
|
-
|
63
|
+
fail "No block provided to ActionSubscriber.draw_routes" unless block_given?
|
64
|
+
|
65
|
+
# We need to delay the execution of this block because ActionSubscriber is
|
66
|
+
# not configured at this point if we're calling from within the required app.
|
67
|
+
@route_set = nil
|
68
|
+
@draw_routes_block = block
|
64
69
|
end
|
65
70
|
|
66
71
|
def self.logger
|
@@ -121,8 +126,13 @@ module ActionSubscriber
|
|
121
126
|
#
|
122
127
|
def self.route_set
|
123
128
|
@route_set ||= begin
|
124
|
-
|
125
|
-
|
129
|
+
if @draw_routes_block
|
130
|
+
routes = Router.draw_routes(&@draw_routes_block)
|
131
|
+
RouteSet.new(routes)
|
132
|
+
else
|
133
|
+
logger.warn "DEPRECATION WARNING: We are inferring your routes by looking at your subscribers. This behavior is deprecated and will be removed in version 2.0. Please see the routing guide at https://github.com/mxenabled/action_subscriber/blob/master/routing.md"
|
134
|
+
RouteSet.new(self.send(:default_routes))
|
135
|
+
end
|
126
136
|
end
|
127
137
|
end
|
128
138
|
private_class_method :route_set
|
@@ -12,14 +12,17 @@ module ActionSubscriber
|
|
12
12
|
:host,
|
13
13
|
:hosts,
|
14
14
|
:mode,
|
15
|
+
:password,
|
15
16
|
:pop_interval,
|
16
17
|
:port,
|
17
18
|
:prefetch,
|
18
19
|
:publisher_confirms,
|
19
20
|
:seconds_to_wait_for_graceful_shutdown,
|
21
|
+
:username,
|
20
22
|
:threadpool_size,
|
21
23
|
:timeout,
|
22
|
-
:times_to_pop
|
24
|
+
:times_to_pop,
|
25
|
+
:virtual_host
|
23
26
|
|
24
27
|
DEFAULTS = {
|
25
28
|
:allow_low_priority_methods => false,
|
@@ -39,7 +42,10 @@ module ActionSubscriber
|
|
39
42
|
:seconds_to_wait_for_graceful_shutdown => 30,
|
40
43
|
:threadpool_size => 8,
|
41
44
|
:timeout => 1,
|
42
|
-
:times_to_pop => 8
|
45
|
+
:times_to_pop => 8,
|
46
|
+
:username => "guest",
|
47
|
+
:password => "guest",
|
48
|
+
:virtual_host => "/"
|
43
49
|
}
|
44
50
|
|
45
51
|
##
|
@@ -89,6 +95,13 @@ module ActionSubscriber
|
|
89
95
|
self.decoder.merge!(decoders)
|
90
96
|
end
|
91
97
|
|
98
|
+
def connection_string=(url)
|
99
|
+
settings = ::ActionSubscriber::URI.parse_amqp_url(url)
|
100
|
+
settings.each do |key, value|
|
101
|
+
send("#{key}=", value)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
92
105
|
def hosts
|
93
106
|
return @hosts if @hosts.size > 0
|
94
107
|
[ host ]
|
@@ -62,10 +62,13 @@ module ActionSubscriber
|
|
62
62
|
|
63
63
|
def self.connection_options
|
64
64
|
{
|
65
|
+
:continuation_timeout => ::ActionSubscriber.configuration.timeout * 1_000.0, #convert sec to ms
|
65
66
|
:heartbeat => ::ActionSubscriber.configuration.heartbeat,
|
66
67
|
:hosts => ::ActionSubscriber.configuration.hosts,
|
68
|
+
:pass => ::ActionSubscriber.configuration.password,
|
67
69
|
:port => ::ActionSubscriber.configuration.port,
|
68
|
-
:
|
70
|
+
:user => ::ActionSubscriber.configuration.username,
|
71
|
+
:vhost => ::ActionSubscriber.configuration.virtual_host,
|
69
72
|
:automatically_recover => true,
|
70
73
|
:network_recovery_interval => NETWORK_RECOVERY_INTERVAL,
|
71
74
|
:recover_from_connection_close => true,
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Taken and adapted from https://github.com/ruby-amqp/amq-protocol/blob/master/lib/amq/uri.rb
|
2
|
+
require "cgi"
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
module ActionSubscriber
|
6
|
+
class URI
|
7
|
+
AMQP_PORTS = {"amqp" => 5672, "amqps" => 5671}.freeze
|
8
|
+
|
9
|
+
def self.parse_amqp_url(connection_string)
|
10
|
+
uri = ::URI.parse(connection_string)
|
11
|
+
raise ArgumentError.new("Connection URI must use amqp or amqps schema (example: amqp://bus.megacorp.internal:5766), learn more at http://bit.ly/ks8MXK") unless %w{amqp amqps}.include?(uri.scheme)
|
12
|
+
|
13
|
+
opts = {}
|
14
|
+
|
15
|
+
opts[:username] = ::CGI::unescape(uri.user) if uri.user
|
16
|
+
opts[:password] = ::CGI::unescape(uri.password) if uri.password
|
17
|
+
opts[:host] = uri.host if uri.host
|
18
|
+
opts[:port] = uri.port || AMQP_PORTS[uri.scheme]
|
19
|
+
|
20
|
+
if uri.path =~ %r{^/(.*)}
|
21
|
+
raise ArgumentError.new("#{uri} has multiple-segment path; please percent-encode any slashes in the vhost name (e.g. /production => %2Fproduction). Learn more at http://bit.ly/amqp-gem-and-connection-uris") if $1.index('/')
|
22
|
+
opts[:virtual_host] = ::CGI::unescape($1)
|
23
|
+
end
|
24
|
+
|
25
|
+
opts
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -33,6 +33,13 @@ describe "A Subscriber With Inferred Routes", :integration => true do
|
|
33
33
|
|
34
34
|
# This is the deprecated behavior we want to keep until version 2.0
|
35
35
|
context "no explicit routes" do
|
36
|
+
before do
|
37
|
+
# TEST HACK: Bust any memoized routes.
|
38
|
+
::ActionSubscriber.instance_variable_set(:@route_set, nil)
|
39
|
+
::ActionSubscriber.instance_variable_set(:@draw_routes_block, nil)
|
40
|
+
::ActionSubscriber.setup_queues!
|
41
|
+
end
|
42
|
+
|
36
43
|
it "registers the routes and sets up the queues" do
|
37
44
|
::ActionSubscriber.auto_subscribe!
|
38
45
|
::ActionSubscriber::Publisher.publish("kyle.inference.yo", "YO", "events")
|
@@ -5,6 +5,7 @@ describe ::ActionSubscriber::Configuration do
|
|
5
5
|
specify { expect(subject.async_publisher_drop_messages_when_queue_full).to eq(false) }
|
6
6
|
specify { expect(subject.async_publisher_max_queue_size).to eq(1_000_000) }
|
7
7
|
specify { expect(subject.async_publisher_supervisor_interval).to eq(200) }
|
8
|
+
specify { expect(subject.default_exchange).to eq("events") }
|
8
9
|
specify { expect(subject.heartbeat).to eq(5) }
|
9
10
|
specify { expect(subject.host).to eq("localhost") }
|
10
11
|
specify { expect(subject.mode).to eq('subscribe') }
|
@@ -37,4 +38,15 @@ describe ::ActionSubscriber::Configuration do
|
|
37
38
|
}.to raise_error(/The foo decoder was given with arity of 2/)
|
38
39
|
end
|
39
40
|
end
|
41
|
+
|
42
|
+
describe "connection_string" do
|
43
|
+
it "explodes the connection string into the corresponding settings" do
|
44
|
+
subject.connection_string = "amqp://user:pass@host:100/vhost"
|
45
|
+
expect(subject.username).to eq("user")
|
46
|
+
expect(subject.password).to eq("pass")
|
47
|
+
expect(subject.host).to eq("host")
|
48
|
+
expect(subject.port).to eq(100)
|
49
|
+
expect(subject.virtual_host).to eq("vhost")
|
50
|
+
end
|
51
|
+
end
|
40
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Brian Stien
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2016-02-
|
15
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- lib/action_subscriber/rspec.rb
|
224
224
|
- lib/action_subscriber/subscribable.rb
|
225
225
|
- lib/action_subscriber/threadpool.rb
|
226
|
+
- lib/action_subscriber/uri.rb
|
226
227
|
- lib/action_subscriber/version.rb
|
227
228
|
- routing.md
|
228
229
|
- spec/integration/around_filters_spec.rb
|
@@ -269,9 +270,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
269
270
|
version: '0'
|
270
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
272
|
requirements:
|
272
|
-
- - "
|
273
|
+
- - ">="
|
273
274
|
- !ruby/object:Gem::Version
|
274
|
-
version:
|
275
|
+
version: '0'
|
275
276
|
requirements: []
|
276
277
|
rubyforge_project:
|
277
278
|
rubygems_version: 2.4.8
|