krakow 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/krakow/connection.rb +40 -50
- data/lib/krakow/consumer.rb +1 -1
- data/lib/krakow/producer.rb +3 -0
- data/lib/krakow/version.rb +1 -1
- 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: 58808267d1e6b93d05a47f6c3a1caaf0f7199e32
|
4
|
+
data.tar.gz: c8f9d22593eae52540d0b5aa66ef2f4f58b33312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 498a16a7bd795a5d06de3cc3ba8c82aff77947f3e293f61d2c86e08779d00883a49e60297744465722b74618807ea9eaed88f82778317b8994a4846d31193d54
|
7
|
+
data.tar.gz: cb9d189af74350e55643b31227588eb0ae114c7e35d6f78c1e143c6b573b6ba44a6c2dc508630cb1edc73b7bd57761e44e740df8289925878572ff7fabf10c14
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## v0.3.8
|
2
|
+
* Remove locks and move logic to connection access
|
3
|
+
* Check for result within response prior to access (prevent slaying actor)
|
4
|
+
|
1
5
|
## v0.3.6
|
2
6
|
* Allow `:options` key within `Producer` to set low level connection settings
|
3
7
|
* Make snappy an optional dependency
|
data/lib/krakow/connection.rb
CHANGED
@@ -50,7 +50,10 @@ module Krakow
|
|
50
50
|
# @return [Socket-ish] underlying socket like instance
|
51
51
|
attr_reader :socket
|
52
52
|
|
53
|
-
|
53
|
+
# set exclusive methods
|
54
|
+
exclusive :init!
|
55
|
+
|
56
|
+
attr_reader :reconnect_notifier, :running
|
54
57
|
|
55
58
|
# @!group Attributes
|
56
59
|
|
@@ -95,9 +98,6 @@ module Krakow
|
|
95
98
|
# @option args [Hash] :feature_args options for connection features
|
96
99
|
def initialize(args={})
|
97
100
|
super
|
98
|
-
@connector = Mutex.new
|
99
|
-
@reconnector = Mutex.new
|
100
|
-
@responder = Mutex.new
|
101
101
|
@reconnect_notifier = Celluloid::Signals.new
|
102
102
|
@socket_retries = 0
|
103
103
|
@socket_max_retries = 10
|
@@ -120,9 +120,7 @@ module Krakow
|
|
120
120
|
#
|
121
121
|
# @return [nil]
|
122
122
|
def init!
|
123
|
-
|
124
|
-
connect!
|
125
|
-
end
|
123
|
+
connect!
|
126
124
|
nil
|
127
125
|
end
|
128
126
|
|
@@ -147,27 +145,25 @@ module Krakow
|
|
147
145
|
# @param message [Krakow::Message] message to send
|
148
146
|
# @return [Krakow::FrameType] response
|
149
147
|
def transmit_with_response(message, wait_time)
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
148
|
+
safe_socket{|socket| socket.write(message.to_line) }
|
149
|
+
responses.clear
|
150
|
+
response = nil
|
151
|
+
(wait_time / response_interval).to_i.times do |i|
|
152
|
+
response = responses.pop unless responses.empty?
|
153
|
+
break if response
|
154
|
+
sleep(response_interval)
|
155
|
+
end
|
156
|
+
if(response)
|
157
|
+
message.response = response
|
158
|
+
if(message.error?(response))
|
159
|
+
res = Error::BadResponse.new "Message transmission failed #{message}"
|
160
|
+
res.result = response
|
161
|
+
abort res
|
158
162
|
end
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
res.result = response
|
164
|
-
abort res
|
165
|
-
end
|
166
|
-
response
|
167
|
-
else
|
168
|
-
unless(Command.response_for(message) == :error_only)
|
169
|
-
abort Error::BadResponse::NoResponse.new "No response provided for message #{message}"
|
170
|
-
end
|
163
|
+
response
|
164
|
+
else
|
165
|
+
unless(Command.response_for(message) == :error_only)
|
166
|
+
abort Error::BadResponse::NoResponse.new "No response provided for message #{message}"
|
171
167
|
end
|
172
168
|
end
|
173
169
|
end
|
@@ -233,7 +229,7 @@ module Krakow
|
|
233
229
|
if(message)
|
234
230
|
debug "Adding message to queue #{message}"
|
235
231
|
queue << message
|
236
|
-
notifier.
|
232
|
+
notifier.broadcast(message) if notifier
|
237
233
|
end
|
238
234
|
rescue Error::ConnectionUnavailable => e
|
239
235
|
warn "Failed to receive message: #{e.class} - #{e}"
|
@@ -440,30 +436,24 @@ module Krakow
|
|
440
436
|
#
|
441
437
|
# @return [nil]
|
442
438
|
def reconnect!
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
abort ConnectionFailure.new "Failed to re-establish connection after #{@socket_retries} tries."
|
447
|
-
end
|
448
|
-
pause_interval = @reconnect_pause * @socket_retries
|
449
|
-
@socket_retries += 1
|
450
|
-
warn "Pausing for #{pause_interval} seconds before reconnect"
|
451
|
-
sleep(pause_interval)
|
452
|
-
init!
|
453
|
-
@socket_retries = 0
|
454
|
-
rescue Celluloid::Error => e
|
455
|
-
warn "Internal error encountered. Allowing exception to bubble. #{e.class}: #{e}"
|
456
|
-
abort e
|
457
|
-
rescue SystemCallError, IOError => e
|
458
|
-
error "Reconnect error encountered: #{e.class} - #{e}"
|
459
|
-
retry
|
439
|
+
begin
|
440
|
+
if(@socket_max_retries <= @socket_retries)
|
441
|
+
abort ConnectionFailure.new "Failed to re-establish connection after #{@socket_retries} tries."
|
460
442
|
end
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
443
|
+
pause_interval = @reconnect_pause * @socket_retries
|
444
|
+
@socket_retries += 1
|
445
|
+
warn "Pausing for #{pause_interval} seconds before reconnect"
|
446
|
+
sleep(pause_interval)
|
447
|
+
init!
|
448
|
+
@socket_retries = 0
|
449
|
+
rescue Celluloid::Error => e
|
450
|
+
warn "Internal error encountered. Allowing exception to bubble. #{e.class}: #{e}"
|
451
|
+
abort e
|
452
|
+
rescue SystemCallError, IOError => e
|
453
|
+
error "Reconnect error encountered: #{e.class} - #{e}"
|
454
|
+
retry
|
466
455
|
end
|
456
|
+
callback_for(:reconnect)
|
467
457
|
nil
|
468
458
|
end
|
469
459
|
|
data/lib/krakow/consumer.rb
CHANGED
@@ -202,7 +202,7 @@ module Krakow
|
|
202
202
|
distribution.add_connection(connection)
|
203
203
|
true
|
204
204
|
rescue Error::BadResponse => e
|
205
|
-
debug "Failed to establish connection: #{e.result.error}"
|
205
|
+
debug "Failed to establish connection: #{e.result ? e.result.error : '<No Response!>'}"
|
206
206
|
connection.terminate
|
207
207
|
false
|
208
208
|
end
|
data/lib/krakow/producer.rb
CHANGED
data/lib/krakow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: krakow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid-io
|