persistent_http 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c603374a45a221f16b956c1e98ea37fb1a64000
4
- data.tar.gz: 9a6f984964296ea8ef873c864f44c3b4cd0a7ab7
3
+ metadata.gz: d523aa4ce9ba2f4c152ca0dff6fed4a3fa11db58
4
+ data.tar.gz: 5188aa8505323ede2e9f1651372e6f215132548b
5
5
  SHA512:
6
- metadata.gz: 38efd54a08c13bfc73e763cb5691cc262d030d28fb685c5712f0e56da9bd91e518f708139838a447331f6c42e96758d3102affdf360d1b10ed83a4a8fdb9690e
7
- data.tar.gz: 2622d5d9b68b2521bc126387264d8063d2bfd1a261ea40b93e8123a7bb4c8fc12447812e2c55b535c5ff13414fc9b9dbaeb394ee9c9b008a8ed85e87dc44c3bc
6
+ metadata.gz: c13143f9fd45f59c0ff7d3a34353fa8229aa4af30d723ce0babc33b7d64efa5497afd57fa17a9009389487c68150a6e4bd47f5e23abb807de0ff62e942ccc8f5
7
+ data.tar.gz: 159fef3e71ff5ca9e65a7a75a2a18818dc63c8b0f8d5c63b2e2e7522146f98cd625b37d1d8d201f81a6e9c6c7e47f8817a10983ba8db89d072e44d5396ab21d9
data/History.md CHANGED
@@ -1,6 +1,11 @@
1
1
  PersistentHttp Changelog
2
2
  ========================
3
3
 
4
+ 2.0.2
5
+
6
+ - Add OpenSSL::SSL::SSLError to retriable exceptions if it's defined.
7
+ - Add after_connect option for manipulating connection after connect.
8
+
4
9
  2.0.1
5
10
 
6
11
  - Put default_path, host and port getters back into persistent_http for backwards compatibility
@@ -84,7 +84,7 @@ class PersistentHTTP
84
84
  #
85
85
  # Set +name+ to keep your connections apart from everybody else's. Not
86
86
  # required currently, but highly recommended. Your library name should be
87
- # good enough. This parameter will be required in a future version.
87
+ # good enough.
88
88
  #
89
89
  # +proxy+ may be set to a URI::HTTP or :ENV to pick up proxy options from
90
90
  # the environment. See proxy_from_env for details.
@@ -28,6 +28,18 @@ require 'uri'
28
28
  class PersistentHTTP
29
29
  class Connection
30
30
 
31
+ ##
32
+ # Exceptions rescued for automatic retry on ruby 2.0.0. This overlaps with
33
+ # the exception list for ruby 1.x.
34
+ RETRIED_EXCEPTIONS = [ # :nodoc:
35
+ IOError,
36
+ EOFError,
37
+ Errno::ECONNRESET,
38
+ Errno::ECONNABORTED,
39
+ Errno::EPIPE,
40
+ (OpenSSL::SSL::SSLError if defined? OpenSSL::SSL),
41
+ ].compact
42
+
31
43
  ##
32
44
  # An SSL certificate authority. Setting this will set verify_mode to
33
45
  # VERIFY_PEER.
@@ -118,6 +130,10 @@ class PersistentHTTP
118
130
  # You can use +verify_mode+ to override any default values.
119
131
  attr_accessor :verify_mode
120
132
 
133
+ ##
134
+ # Proc to execute after connect which will get passed the Net::HTTP connection
135
+ attr_accessor :after_connect
136
+
121
137
  ##
122
138
  # Creates a new HTTP Connection.
123
139
  #
@@ -153,6 +169,7 @@ class PersistentHTTP
153
169
  @use_ssl = options[:use_ssl]
154
170
  @verify_callback = options[:verify_callback]
155
171
  @verify_mode = options[:verify_mode]
172
+ @after_connect = options[:after_connect]
156
173
  # Because maybe we want a non-persistent connection and are just using this for the proxy stuff
157
174
  @non_persistent = options[:non_persistent]
158
175
 
@@ -206,6 +223,7 @@ class PersistentHTTP
206
223
 
207
224
  @connection.start
208
225
  @logger.debug { "#{@name} #{@connection}: Connection created" } if @logger
226
+ @after_connect.call(@connection) if @after_connect
209
227
  rescue Errno::ECONNREFUSED
210
228
  raise Error, "connection refused: #{@connection.address}:#{@connection.port}"
211
229
  rescue Errno::EHOSTDOWN
@@ -266,7 +284,7 @@ class PersistentHTTP
266
284
  retry
267
285
  end
268
286
 
269
- rescue IOError, EOFError, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EPIPE => e
287
+ rescue *RETRIED_EXCEPTIONS => e
270
288
  due_to = "(due to #{e.message} - #{e.class})"
271
289
  if retried or not (idempotent? req or @force_retry)
272
290
  @logger.info "#{@name}: Removing connection #{due_to} #{error_message}" if @logger
@@ -1,3 +1,3 @@
1
1
  class PersistentHTTP #:nodoc
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persistent_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Pardee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-21 00:00:00.000000000 Z
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: gene_pool
15
- version_requirements: !ruby/object:Gem::Requirement
14
+ requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - '>='
18
17
  - !ruby/object:Gem::Version
19
18
  version: '1.3'
20
- requirement: !ruby/object:Gem::Requirement
19
+ name: gene_pool
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
21
23
  requirements:
22
24
  - - '>='
23
25
  - !ruby/object:Gem::Version
24
26
  version: '1.3'
25
- prerelease: false
26
- type: :runtime
27
27
  description: Persistent HTTP connections using a connection pool
28
28
  email:
29
29
  - bradpardee@gmail.com