sensu-transport 2.2.0 → 2.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9e2efea48fe1374767d24f2bf1fe5e196e84b2e
4
- data.tar.gz: 6175da2fa7df37256fc506f350e8c210220027ff
3
+ metadata.gz: b2445b981319329c16442ba79d0cf1bd2e2d07a3
4
+ data.tar.gz: 5e2c041d677ae778193b4b9c2c5983e5cec0dad7
5
5
  SHA512:
6
- metadata.gz: 553bd1fd716d1e9d4db0d8e1c6bec9ffd8979dfe9052516c4a24356100184a66851b1d6aed00a00a36096aa64961c1b9ce8390a3a510bcffe1f4cb741e579dd5
7
- data.tar.gz: d21146d0ffbaf397dee465dae275cf9af269dc13892c276e6544faeeb7562c72c4d1d1570c4139acc33e2fe88b0b8b4980dead7b46bd9f150f3184d6535b6bd8
6
+ metadata.gz: e61049fd3510dc58237c842d2f71f5f86381695a5380ce9ef6bb64a5d087aa5fd5f1accbc8e852f014eb4799649fed54d03096b4aedc170114db0abb35d19d8c
7
+ data.tar.gz: ad9bcaa6d5fbd8f08ed8093f168f362c10ebf4b25e26c80f5c264491a9e68cd1bc3a39899f72b8707f557f98682c508d8b56525f28005bfd89618b0e657ddff6
@@ -19,16 +19,7 @@ module Sensu
19
19
  @reconnecting = true
20
20
  @before_reconnect.call
21
21
  reset
22
- timer = EM::PeriodicTimer.new(5) do
23
- unless connected?
24
- connect_with_eligible_options do
25
- @reconnecting = false
26
- @after_reconnect.call
27
- end
28
- else
29
- timer.cancel
30
- end
31
- end
22
+ periodically_reconnect
32
23
  end
33
24
  end
34
25
 
@@ -123,13 +114,7 @@ module Sensu
123
114
  Proc.new { reconnect }
124
115
  end
125
116
 
126
- def connection_error(error)
127
- @logger.error("[amqp] Detected TCP connection failure: #{error}") if @logger
128
- reconnect
129
- end
130
-
131
- def connect_with_eligible_options(&callback)
132
- options = next_connection_options
117
+ def setup_connection(options={}, &callback)
133
118
  @connection = AMQP.connect(options)
134
119
  @connection.on_tcp_connection_failure(&reconnect_callback)
135
120
  @connection.on_possible_authentication_failure(&reconnect_callback)
@@ -140,11 +125,6 @@ module Sensu
140
125
  end
141
126
  @connection.on_tcp_connection_loss(&reconnect_callback)
142
127
  @connection.on_skipped_heartbeats(&reconnect_callback)
143
- setup_channel(options)
144
- rescue EventMachine::ConnectionError => error
145
- connection_error(error)
146
- rescue Java::JavaLang::RuntimeException => error
147
- connection_error(error)
148
128
  end
149
129
 
150
130
  def setup_channel(options={})
@@ -160,6 +140,29 @@ module Sensu
160
140
  end
161
141
  @channel.prefetch(prefetch)
162
142
  end
143
+
144
+ def connect_with_eligible_options(&callback)
145
+ options = next_connection_options
146
+ setup_connection(options, &callback)
147
+ setup_channel(options)
148
+ end
149
+
150
+ def periodically_reconnect
151
+ timer = EM::PeriodicTimer.new(5) do
152
+ unless connected?
153
+ begin
154
+ connect_with_eligible_options do
155
+ @reconnecting = false
156
+ @after_reconnect.call
157
+ end
158
+ rescue EventMachine::ConnectionError
159
+ rescue Java::JavaLang::RuntimeException
160
+ end
161
+ else
162
+ timer.cancel
163
+ end
164
+ end
165
+ end
163
166
  end
164
167
  end
165
168
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-transport"
5
- spec.version = "2.2.0"
5
+ spec.version = "2.3.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu transport abstraction library"
@@ -108,11 +108,11 @@ describe "Sensu::Transport::RabbitMQ" do
108
108
  end
109
109
  end
110
110
 
111
- it "can handle eventmachine connection errors" do
111
+ it "will throw an error if it cannot resolve a hostname" do
112
112
  async_wrapper do
113
113
  expect {
114
114
  @transport.connect(:host => "2def33c3-cfbb-4993-b5ee-08d47f6d8793")
115
- }.not_to raise_error
115
+ }.to raise_error
116
116
  async_done
117
117
  end
118
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter