klomp 1.0.3 → 1.0.4
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.
- data/ChangeLog.md +5 -0
- data/klomp.gemspec +1 -1
- data/lib/klomp.rb +1 -1
- data/lib/klomp/connection.rb +4 -2
- data/spec/klomp/connection_spec.rb +12 -1
- metadata +2 -2
data/ChangeLog.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
Klomp Changes
|
2
2
|
--------------------------------------------------------------------------------
|
3
3
|
|
4
|
+
1.0.4 (2012/10/10)
|
5
|
+
================================================================================
|
6
|
+
|
7
|
+
- Guard against sentinel creating a second one if it encounters exceptions
|
8
|
+
|
4
9
|
1.0.3 (2012/10/10)
|
5
10
|
================================================================================
|
6
11
|
|
data/klomp.gemspec
CHANGED
data/lib/klomp.rb
CHANGED
data/lib/klomp/connection.rb
CHANGED
@@ -76,6 +76,7 @@ class Klomp
|
|
76
76
|
subs = subscriptions.dup
|
77
77
|
subscriptions.clear
|
78
78
|
subs.each {|queue, subscriber| subscribe(queue, subscriber) }
|
79
|
+
@sentinel = nil
|
79
80
|
end
|
80
81
|
|
81
82
|
private
|
@@ -120,7 +121,7 @@ class Klomp
|
|
120
121
|
return unless logger.debug?
|
121
122
|
body = frame.body
|
122
123
|
body = body.lines.first.chomp + '...' if body =~ /\n/
|
123
|
-
logger.debug "frame=#{frame.name} #{frame.headers.map{|k,v| k + '=' + v }.join(' ')} body=#{body}"
|
124
|
+
logger.debug "frame=#{frame.name} #{frame.headers.map{|k,v| k.to_s + '=' + v.to_s.inspect }.join(' ')} body=#{body}"
|
124
125
|
end
|
125
126
|
|
126
127
|
def log_exception(ex, level = :error, msg_start = '')
|
@@ -134,9 +135,10 @@ class Klomp
|
|
134
135
|
|
135
136
|
def go_offline(ex)
|
136
137
|
log_exception(ex, :warn, "offline server=#{options['server'].join(':')} ") if logger
|
138
|
+
return if @sentinel && @sentinel.alive?
|
137
139
|
@socket.close rescue nil
|
138
140
|
@socket = nil
|
139
|
-
Sentinel.new(self)
|
141
|
+
@sentinel = Sentinel.new(self)
|
140
142
|
stop_subscriber_thread
|
141
143
|
end
|
142
144
|
|
@@ -9,12 +9,13 @@ describe Klomp::Connection do
|
|
9
9
|
Given(:logger) { double("Logger", error:nil, warn:nil, info:nil, debug:nil).as_null_object }
|
10
10
|
Given(:subscriber) { double "subscriber", call:nil }
|
11
11
|
Given(:thread) { double Thread }
|
12
|
+
Given(:sentinel) { double Klomp::Sentinel, alive?:true }
|
12
13
|
|
13
14
|
Given do
|
14
15
|
IO.stub!(:select).and_return([[socket], [socket]])
|
15
16
|
TCPSocket.stub!(:new).and_return socket
|
16
17
|
Thread.stub!(:new).and_return {|*args,&blk| thread.stub!(:block => blk); thread }
|
17
|
-
Klomp::Sentinel.stub!(new:
|
18
|
+
Klomp::Sentinel.stub!(new: sentinel)
|
18
19
|
end
|
19
20
|
|
20
21
|
context "new" do
|
@@ -275,6 +276,16 @@ describe Klomp::Connection do
|
|
275
276
|
Klomp::Sentinel.should have_received(:new).with(connection)
|
276
277
|
end
|
277
278
|
|
279
|
+
context "only once" do
|
280
|
+
|
281
|
+
Then do
|
282
|
+
expect_publish.to raise_error(SystemCallError)
|
283
|
+
connection.send(:go_offline, begin; raise "error"; rescue; $!; end)
|
284
|
+
Klomp::Sentinel.should have_received(:new).with(connection).once
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
288
|
+
|
278
289
|
end
|
279
290
|
|
280
291
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klomp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -224,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
segments:
|
226
226
|
- 0
|
227
|
-
hash:
|
227
|
+
hash: 1370034990818288756
|
228
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
229
|
none: false
|
230
230
|
requirements:
|