persistent_http 1.0.3 → 1.0.4

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.
data/History.md CHANGED
@@ -1,6 +1,11 @@
1
1
  PersistentHttp Changelog
2
2
  ========================
3
3
 
4
+ 1.0.4
5
+
6
+ - Added option :pool_timeout which will raise a Timeout::Error if unable to checkout a connection
7
+ within this time.
8
+
4
9
  1.0.3
5
10
 
6
11
  - Allow option idle_timeout which will renew connection that haven't been used in this amount of time.
data/README.rdoc CHANGED
@@ -34,6 +34,7 @@ returned.
34
34
  :name => 'MyHTTPClient',
35
35
  :logger => Rails.logger,
36
36
  :pool_size => 10,
37
+ :pool_timeout => 5,
37
38
  :warn_timeout => 0.25,
38
39
  :force_retry => true,
39
40
  :url => 'https://www.example.com/echo/foo' # equivalent to :use_ssl => true, :host => 'www.example.com', :default_path => '/echo/foo'
@@ -105,6 +105,9 @@ class PersistentHTTP
105
105
  # from everybody else's.
106
106
  attr_reader :name
107
107
 
108
+ ##
109
+ # Seconds to wait for an available connection before a Timeout::Error is raised
110
+ attr_accessor :pool_timeout
108
111
  ##
109
112
  # Seconds to wait until a connection is opened. See Net::HTTP#open_timeout
110
113
  attr_accessor :open_timeout
@@ -178,6 +181,7 @@ class PersistentHTTP
178
181
  @idle_timeout = options[:idle_timeout] || 10
179
182
  @keep_alive = options[:keep_alive] || 30
180
183
  @logger = options[:logger]
184
+ @pool_timeout = options[:pool_timeout]
181
185
  @open_timeout = options[:open_timeout]
182
186
  @pool_size = options[:pool_size] || 1
183
187
  @port = options[:port]
@@ -231,6 +235,7 @@ class PersistentHTTP
231
235
 
232
236
  @pool = GenePool.new(:name => name + '-' + connection_id,
233
237
  :pool_size => @pool_size,
238
+ :timeout => @pool_timeout,
234
239
  :warn_timeout => @warn_timeout,
235
240
  :idle_timeout => @idle_timeout,
236
241
  :close_proc => nil,
@@ -0,0 +1,36 @@
1
+ require 'net/protocol'
2
+
3
+ ##
4
+ # Aaron Patterson's monkeypatch (accepted into 1.9.1) to fix Net::HTTP's speed
5
+ # problems.
6
+ #
7
+ # http://gist.github.com/251244
8
+
9
+ class Net::BufferedIO #:nodoc:
10
+ alias :old_rbuf_fill :rbuf_fill
11
+
12
+ def rbuf_fill
13
+ if @io.respond_to? :read_nonblock then
14
+ begin
15
+ @rbuf << @io.read_nonblock(65536)
16
+ rescue Errno::EWOULDBLOCK => e
17
+ retry if IO.select [@io], nil, nil, @read_timeout
18
+ raise Timeout::Error, e.message
19
+ end
20
+ else # SSL sockets do not have read_nonblock
21
+ timeout @read_timeout do
22
+ @rbuf << @io.sysread(65536)
23
+ end
24
+ end
25
+ end
26
+ end if RUBY_VERSION < '1.9'
27
+
28
+ class Net::BufferedIO
29
+ def rbuf_fill
30
+ if IO.select [@io], [@io], nil, @read_timeout
31
+ @io.sysread BUFSIZE, @rbuf
32
+ else
33
+ raise Timeout::Error
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persistent_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,19 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-23 00:00:00.000000000Z
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gene_pool
16
- requirement: &70307428283760 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.2.3
21
+ version: '1.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70307428283760
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
25
30
  description: Persistent HTTP connections using a connection pool
26
31
  email:
27
32
  - bradpardee@gmail.com
@@ -30,6 +35,7 @@ extensions: []
30
35
  extra_rdoc_files: []
31
36
  files:
32
37
  - lib/persistent_http/faster.rb
38
+ - lib/persistent_http/faster.rb.sav
33
39
  - lib/persistent_http.rb
34
40
  - LICENSE
35
41
  - Rakefile
@@ -49,16 +55,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
55
  version: '0'
50
56
  segments:
51
57
  - 0
52
- hash: 1575083792056882891
58
+ hash: -3430403703717422601
53
59
  required_rubygems_version: !ruby/object:Gem::Requirement
54
60
  none: false
55
61
  requirements:
56
62
  - - ! '>='
57
63
  - !ruby/object:Gem::Version
58
64
  version: '0'
65
+ segments:
66
+ - 0
67
+ hash: -3430403703717422601
59
68
  requirements: []
60
69
  rubyforge_project:
61
- rubygems_version: 1.8.10
70
+ rubygems_version: 1.8.23
62
71
  signing_key:
63
72
  specification_version: 3
64
73
  summary: Persistent HTTP connections using a connection pool