happening 0.0.8 → 0.0.9

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.
Files changed (2) hide show
  1. data/lib/happening/s3/request.rb +9 -6
  2. metadata +2 -2
@@ -27,7 +27,7 @@ module Happening
27
27
  end
28
28
 
29
29
  def execute
30
- Happening::Log.debug "#{http_method.to_s.upcase} #{url}"
30
+ Happening::Log.debug "Request: #{http_method.to_s.upcase} #{url}"
31
31
  @response = http_class.new(url).send(http_method, :timeout => options[:timeout], :head => options[:headers], :body => options[:data], :ssl => options[:ssl])
32
32
 
33
33
  @response.errback { error_callback }
@@ -46,8 +46,11 @@ module Happening
46
46
  end
47
47
 
48
48
  def error_callback
49
- Happening::Log.error "#{http_method.to_s.upcase} #{url}: Response #{response.response_header.status rescue ''}"
50
- if options[:on_error].respond_to?(:call)
49
+ Happening::Log.error "Response error: #{http_method.to_s.upcase} #{url}: #{response.response_header.status rescue ''}"
50
+ if should_retry?
51
+ Happening::Log.info "#{http_method.to_s.upcase} #{url}: retrying after error: status #{response.response_header.status rescue ''}"
52
+ handle_retry
53
+ elsif options[:on_error].respond_to?(:call)
51
54
  call_user_error_handler
52
55
  else
53
56
  raise Happening::Error.new("#{http_method.to_s.upcase} #{url}: Failed reponse! Status code was #{response.response_header.status rescue ''}")
@@ -55,13 +58,14 @@ module Happening
55
58
  end
56
59
 
57
60
  def success_callback
58
- Happening::Log.debug "#{http_method.to_s.upcase} #{url}: Response #{response.response_header.status rescue ''}"
61
+ Happening::Log.debug "Response success: #{http_method.to_s.upcase} #{url}: #{response.response_header.status rescue ''}"
59
62
  case response.response_header.status
60
63
  when 0, 400, 401, 404, 403, 409, 411, 412, 416, 500, 503
61
64
  if should_retry?
62
- Happening::Log.debug "#{http_method.to_s.upcase} #{url}: retrying after: status #{response.response_header.status rescue ''}"
65
+ Happening::Log.info "#{http_method.to_s.upcase} #{url}: retrying after: status #{response.response_header.status rescue ''}"
63
66
  handle_retry
64
67
  else
68
+ Happening::Log.error "#{http_method.to_s.upcase} #{url}: Re-tried too often - giving up"
65
69
  error_callback
66
70
  end
67
71
  when 300, 301, 303, 304, 307
@@ -84,7 +88,6 @@ module Happening
84
88
  options[:retry_count] > 0
85
89
  end
86
90
 
87
-
88
91
  def handle_retry
89
92
  if should_retry?
90
93
  new_request = self.class.new(http_method, url, options.update(:retry_count => options[:retry_count] - 1 ))
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Weiss