action_subscriber 3.0.0.pre1-java → 3.0.0.pre2-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/middleware/error_handler.rb +18 -9
- data/lib/action_subscriber/rabbit_connection.rb +4 -2
- data/lib/action_subscriber/router.rb +3 -2
- data/lib/action_subscriber/version.rb +1 -1
- data/spec/lib/action_subscriber/middleware/error_handler_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65fce1739063a1cf33dba2d29452a76add18ea96
|
4
|
+
data.tar.gz: 75d402b7e378ae9cf3d1eae35e694ffc23f4373c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a7fa9c4143d3eef353301118acda43ca49b9c6bc7a07a846bc75e100aa6eefb926e31b8934b146dddb49bac572b9a2c74c3dcb860cc1cb23ddaa6c5fadd7ec6
|
7
|
+
data.tar.gz: 5861f99195162aec8d18c4d436f65f0ffda7a3e9438175218568770eaf17f54a00f1202fef76d661661a237b4375d5055e8fcb24634c509b2189e0e58a867951
|
@@ -8,17 +8,26 @@ module ActionSubscriber
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(env)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
job_mutex = ::Mutex.new
|
12
|
+
job_complete = ::ConditionVariable.new
|
13
|
+
|
14
|
+
job_mutex.synchronize do
|
15
|
+
::Thread.new do
|
16
|
+
job_mutex.synchronize do
|
17
|
+
begin
|
18
|
+
@app.call(env)
|
19
|
+
rescue => error
|
20
|
+
logger.error "FAILED #{env.message_id}"
|
21
|
+
::ActionSubscriber.configuration.error_handler.call(error, env.to_h)
|
22
|
+
ensure
|
23
|
+
job_complete.signal
|
24
|
+
end
|
25
|
+
end
|
19
26
|
end
|
27
|
+
|
28
|
+
# TODO we might want to pass a timeout to this wait so we can handle jobs that get frozen
|
29
|
+
job_complete.wait(job_mutex)
|
20
30
|
end
|
21
|
-
::Thread.pass while new_thread.alive?
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|
@@ -13,13 +13,15 @@ module ActionSubscriber
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.subscriber_connected?
|
16
|
-
|
16
|
+
SUBSCRIBER_CONNECTION_MUTEX.synchronize do
|
17
|
+
subscriber_connections.all?{|_name, connection| connection.connected?}
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.subscriber_disconnect!
|
20
22
|
SUBSCRIBER_CONNECTION_MUTEX.synchronize do
|
21
23
|
subscriber_connections.each{|_name, connection| connection.close}
|
22
|
-
@subscriber_connections =
|
24
|
+
@subscriber_connections = {}
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -40,8 +40,9 @@ module ActionSubscriber
|
|
40
40
|
].compact.join(".")
|
41
41
|
end
|
42
42
|
|
43
|
-
def default_routes_for(subscriber)
|
44
|
-
|
43
|
+
def default_routes_for(subscriber, options = {})
|
44
|
+
options = options.merge({:connection_name => @current_connection_name})
|
45
|
+
subscriber.routes(options).each do |route|
|
45
46
|
routes << route
|
46
47
|
end
|
47
48
|
end
|
@@ -19,4 +19,19 @@ describe ActionSubscriber::Middleware::ErrorHandler do
|
|
19
19
|
subject.call(env)
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
context "many concurrent threads" do
|
24
|
+
it "handles the race conditions without raising exceptions" do
|
25
|
+
no_op = lambda{ nil }
|
26
|
+
threads = 1.upto(100).map do
|
27
|
+
::Thread.new do
|
28
|
+
::Thread.current.abort_on_exception = true
|
29
|
+
100.times do
|
30
|
+
described_class.new(no_op).call(env)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
threads.each(&:join)
|
35
|
+
end
|
36
|
+
end
|
22
37
|
end
|
data/spec/spec_helper.rb
CHANGED
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: 3.0.0.
|
4
|
+
version: 3.0.0.pre2
|
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-09-
|
15
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|