right_amqp 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/right_amqp/amqp/client.rb +7 -16
- data/right_amqp.gemspec +3 -3
- data/spec/amqp/client_extensions_spec.rb +13 -2
- metadata +46 -14
@@ -247,13 +247,7 @@ module AMQP
|
|
247
247
|
def reconnect force = false
|
248
248
|
if @reconnecting and not force
|
249
249
|
# Wait after first reconnect attempt and in between each subsequent attempt
|
250
|
-
EM.add_timer(@settings[:reconnect_interval] || 5)
|
251
|
-
begin
|
252
|
-
reconnect(true)
|
253
|
-
rescue Exception => e
|
254
|
-
logger.exception("[amqp] Failed to reconnect", e, :trace)
|
255
|
-
end
|
256
|
-
end
|
250
|
+
EM.add_timer(@settings[:reconnect_interval] || 5) { reconnect(true) }
|
257
251
|
return
|
258
252
|
end
|
259
253
|
|
@@ -271,13 +265,7 @@ module AMQP
|
|
271
265
|
again = again.call if again.is_a?(Proc)
|
272
266
|
if again.is_a?(Numeric)
|
273
267
|
# Wait before making initial reconnect attempt
|
274
|
-
EM.add_timer(again)
|
275
|
-
begin
|
276
|
-
reconnect(true)
|
277
|
-
rescue Exception => e
|
278
|
-
logger.exception("[amqp] Failed to reconnect", e, :trace)
|
279
|
-
end
|
280
|
-
end
|
268
|
+
EM.add_timer(again) { reconnect(true) }
|
281
269
|
return
|
282
270
|
elsif ![nil, true].include?(again)
|
283
271
|
raise ::AMQP::Error, "Could not interpret :reconnect_delay => #{again.inspect}; expected nil, true, or Numeric"
|
@@ -287,6 +275,9 @@ module AMQP
|
|
287
275
|
log 'reconnecting'
|
288
276
|
logger.info("[amqp] Attempting to reconnect to #{@settings[:identity]}")
|
289
277
|
EM.reconnect(@settings[:host], @settings[:port], self)
|
278
|
+
rescue Exception => e
|
279
|
+
logger.exception("[amqp] Failed to reconnect", e, :trace)
|
280
|
+
failed
|
290
281
|
end
|
291
282
|
|
292
283
|
def self.connect opts = {}
|
@@ -300,14 +291,14 @@ module AMQP
|
|
300
291
|
|
301
292
|
def failed
|
302
293
|
@connection_status.call(:failed) if @connection_status
|
303
|
-
@
|
294
|
+
@has_failed = true
|
304
295
|
close_connection
|
305
296
|
end
|
306
297
|
|
307
298
|
private
|
308
299
|
|
309
300
|
def disconnected
|
310
|
-
unless @
|
301
|
+
unless @has_failed
|
311
302
|
@connection_status.call(:disconnected) if @connection_status
|
312
303
|
reconnect
|
313
304
|
end
|
data/right_amqp.gemspec
CHANGED
@@ -24,8 +24,8 @@ require 'rubygems'
|
|
24
24
|
|
25
25
|
Gem::Specification.new do |spec|
|
26
26
|
spec.name = 'right_amqp'
|
27
|
-
spec.version = '0.
|
28
|
-
spec.date = '2012-
|
27
|
+
spec.version = '0.6.0'
|
28
|
+
spec.date = '2012-12-10'
|
29
29
|
spec.authors = ['Lee Kirchhoff']
|
30
30
|
spec.email = 'lee@rightscale.com'
|
31
31
|
spec.homepage = 'https://github.com/rightscale/right_amqp'
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.require_path = 'lib'
|
39
39
|
|
40
40
|
spec.add_dependency('right_support', ['>= 1.2', '< 3.0'])
|
41
|
-
spec.add_dependency('eventmachine', '
|
41
|
+
spec.add_dependency('eventmachine', ['>= 0.12.10', '< 2.0'])
|
42
42
|
|
43
43
|
spec.description = <<-EOF
|
44
44
|
RightAMQP provides a high availability client for interfacing with the
|
@@ -33,7 +33,7 @@ describe AMQP::Client do
|
|
33
33
|
class SUT
|
34
34
|
include AMQP::Client
|
35
35
|
|
36
|
-
attr_accessor :reconnecting, :settings, :channels
|
36
|
+
attr_accessor :reconnecting, :settings, :channels, :has_failed
|
37
37
|
end
|
38
38
|
|
39
39
|
before(:each) do
|
@@ -88,7 +88,7 @@ describe AMQP::Client do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
context 'with a :reconnect_interval of 5 seconds'
|
91
|
+
context 'with a :reconnect_interval of 5 seconds' do
|
92
92
|
it 'should schedule reconnect attempts on a 5s interval' do
|
93
93
|
@sut.reconnecting = true
|
94
94
|
@sut.settings[:reconnect_delay] = 15
|
@@ -101,6 +101,17 @@ describe AMQP::Client do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
context 'with a reconnect failure' do
|
105
|
+
it 'should fail the connection' do
|
106
|
+
@logger.should_receive(:error).with(/Failed to reconnect/).once
|
107
|
+
flexmock(EM).should_receive(:reconnect).and_raise(Exception).once
|
108
|
+
flexmock(@sut).should_receive(:close_connection).once
|
109
|
+
|
110
|
+
@sut.reconnect()
|
111
|
+
@sut.has_failed.should be_true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
104
115
|
end
|
105
116
|
|
106
117
|
context "heartbeat" do
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 7
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Lee Kirchhoff
|
@@ -10,33 +15,54 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2012-
|
18
|
+
date: 2012-12-10 00:00:00 -08:00
|
19
|
+
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
|
-
|
17
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
18
23
|
none: false
|
19
24
|
requirements:
|
20
25
|
- - ">="
|
21
26
|
- !ruby/object:Gem::Version
|
27
|
+
hash: 11
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 2
|
22
31
|
version: "1.2"
|
23
32
|
- - <
|
24
33
|
- !ruby/object:Gem::Version
|
34
|
+
hash: 7
|
35
|
+
segments:
|
36
|
+
- 3
|
37
|
+
- 0
|
25
38
|
version: "3.0"
|
26
|
-
|
39
|
+
requirement: *id001
|
40
|
+
name: right_support
|
27
41
|
prerelease: false
|
28
|
-
|
42
|
+
type: :runtime
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
|
-
|
31
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
44
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
32
45
|
none: false
|
33
46
|
requirements:
|
34
|
-
- -
|
47
|
+
- - ">="
|
35
48
|
- !ruby/object:Gem::Version
|
49
|
+
hash: 59
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
- 12
|
53
|
+
- 10
|
36
54
|
version: 0.12.10
|
37
|
-
|
55
|
+
- - <
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 0
|
61
|
+
version: "2.0"
|
62
|
+
requirement: *id002
|
63
|
+
name: eventmachine
|
38
64
|
prerelease: false
|
39
|
-
|
65
|
+
type: :runtime
|
40
66
|
description: |
|
41
67
|
RightAMQP provides a high availability client for interfacing with the
|
42
68
|
RightScale RabbitMQ broker using the AMQP protocol. The AMQP version on which
|
@@ -86,6 +112,7 @@ files:
|
|
86
112
|
- spec/ha_client/ha_broker_client_spec.rb
|
87
113
|
- spec/spec.opts
|
88
114
|
- spec/spec_helper.rb
|
115
|
+
has_rdoc: true
|
89
116
|
homepage: https://github.com/rightscale/right_amqp
|
90
117
|
licenses: []
|
91
118
|
|
@@ -102,20 +129,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
129
|
requirements:
|
103
130
|
- - ">="
|
104
131
|
- !ruby/object:Gem::Version
|
132
|
+
hash: 57
|
133
|
+
segments:
|
134
|
+
- 1
|
135
|
+
- 8
|
136
|
+
- 7
|
105
137
|
version: 1.8.7
|
106
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
139
|
none: false
|
108
140
|
requirements:
|
109
141
|
- - ">="
|
110
142
|
- !ruby/object:Gem::Version
|
111
|
-
hash:
|
143
|
+
hash: 3
|
112
144
|
segments:
|
113
145
|
- 0
|
114
146
|
version: "0"
|
115
147
|
requirements: []
|
116
148
|
|
117
149
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 1.3.7
|
119
151
|
signing_key:
|
120
152
|
specification_version: 3
|
121
153
|
summary: Client for interfacing to RightScale RabbitMQ broker using AMQP
|