af_minion 0.1.15.1 → 0.1.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/minion.rb +27 -28
  2. metadata +3 -3
@@ -143,6 +143,32 @@ module Minion
143
143
  AMQP.stop { EM.stop }
144
144
  end
145
145
 
146
+ end
147
+
148
+ def with_bunny_connection_retry
149
+ num_executions = 1
150
+ begin
151
+ yield
152
+ rescue Bunny::ServerDownError, Bunny::ConnectionError => e
153
+ clear_bunny
154
+ if num_executions < NUMBER_OF_RETRIES
155
+ log "Retry ##{num_executions} : #{caller.first}"
156
+ num_executions += 1
157
+ sleep 0.5
158
+ retry
159
+ else
160
+ error = e.class.new(e.message + " (Retried #{NUMBER_OF_RETRIES} times. Giving up.)")
161
+ error.set_backtrace(e.backtrace)
162
+ raise error
163
+ end
164
+ rescue => e
165
+ clear_bunny
166
+ raise e
167
+ end
168
+ end
169
+
170
+ def clear_bunny
171
+ @@bunny = nil
146
172
  end
147
173
 
148
174
  private
@@ -181,34 +207,7 @@ module Minion
181
207
 
182
208
  def exit_handler
183
209
  AMQP.stop { EM.stop }
184
- end
185
-
186
- def with_bunny_connection_retry
187
- num_executions = 1
188
- begin
189
- yield
190
- rescue Bunny::ServerDownError, Bunny::ConnectionError => e
191
- clear_bunny
192
- if num_executions < NUMBER_OF_RETRIES
193
- log "Retry ##{num_executions} : #{caller.first}"
194
- num_executions += 1
195
- sleep 0.5
196
- retry
197
- else
198
- error = e.class.new(e.message + " (Retried #{NUMBER_OF_RETRIES} times. Giving up.)")
199
- error.set_backtrace(e.backtrace)
200
- raise error
201
- end
202
- rescue => e
203
- clear_bunny
204
- raise e
205
- end
206
- end
207
-
208
- def clear_bunny
209
- @@bunny = nil
210
- end
211
-
210
+ end
212
211
 
213
212
  end
214
213
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: af_minion
3
3
  version: !ruby/object:Gem::Version
4
- hash: 121
4
+ hash: 127
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 15
10
- - 1
11
- version: 0.1.15.1
10
+ - 2
11
+ version: 0.1.15.2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Orion Henry