persistent_http 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +6 -1
- data/README.rdoc +2 -2
- data/lib/persistent_http.rb +20 -6
- metadata +8 -5
data/History.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
PersistentHttp Changelog
|
2
|
-
|
2
|
+
========================
|
3
|
+
|
4
|
+
1.0.3
|
5
|
+
|
6
|
+
- Allow option idle_timeout which will renew connection that haven't been used in this amount of time.
|
7
|
+
- Implement shutdown which will close connections as they are checked in.
|
3
8
|
|
4
9
|
1.0.2
|
5
10
|
|
data/README.rdoc
CHANGED
@@ -45,7 +45,7 @@ returned.
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def send_post_message
|
48
|
-
request = Net::HTTP::Post.new('/perform_service)
|
48
|
+
request = Net::HTTP::Post.new('/perform_service')
|
49
49
|
... Modify request as needed ...
|
50
50
|
response = @@persistent_http.request(request)
|
51
51
|
... Handle response as you would a normal Net::HTTPResponse ...
|
@@ -55,4 +55,4 @@ returned.
|
|
55
55
|
|
56
56
|
== Copyright
|
57
57
|
|
58
|
-
Copyright (c) 2010 Eric Hodel, Aaron Patterson, Brad Pardee. See LICENSE for details.
|
58
|
+
Copyright (c) 2010-2012 Eric Hodel, Aaron Patterson, Brad Pardee. See LICENSE for details.
|
data/lib/persistent_http.rb
CHANGED
@@ -82,6 +82,10 @@ class PersistentHTTP
|
|
82
82
|
# HTTP version to enable version specific features.
|
83
83
|
attr_reader :http_version
|
84
84
|
|
85
|
+
##
|
86
|
+
# Connection will be renewed if it hasn't been used in this amount of time. Defaults to 10 seconds.
|
87
|
+
attr_reader :idle_timeout
|
88
|
+
|
85
89
|
##
|
86
90
|
# The value sent in the Keep-Alive header. Defaults to 30. Not needed for
|
87
91
|
# HTTP/1.1 servers.
|
@@ -143,7 +147,7 @@ class PersistentHTTP
|
|
143
147
|
##
|
144
148
|
# The threshold in seconds for checking out a connection at which a warning
|
145
149
|
# will be logged via the logger
|
146
|
-
|
150
|
+
attr_reader :warn_timeout
|
147
151
|
|
148
152
|
##
|
149
153
|
# Creates a new PersistentHTTP.
|
@@ -171,6 +175,7 @@ class PersistentHTTP
|
|
171
175
|
@force_retry = options[:force_retry]
|
172
176
|
@headers = options[:header] || {}
|
173
177
|
@host = options[:host]
|
178
|
+
@idle_timeout = options[:idle_timeout] || 10
|
174
179
|
@keep_alive = options[:keep_alive] || 30
|
175
180
|
@logger = options[:logger]
|
176
181
|
@open_timeout = options[:open_timeout]
|
@@ -227,6 +232,8 @@ class PersistentHTTP
|
|
227
232
|
@pool = GenePool.new(:name => name + '-' + connection_id,
|
228
233
|
:pool_size => @pool_size,
|
229
234
|
:warn_timeout => @warn_timeout,
|
235
|
+
:idle_timeout => @idle_timeout,
|
236
|
+
:close_proc => nil,
|
230
237
|
:logger => @logger) do
|
231
238
|
begin
|
232
239
|
connection = Net::HTTP.new(*net_http_args)
|
@@ -246,6 +253,16 @@ class PersistentHTTP
|
|
246
253
|
end
|
247
254
|
end
|
248
255
|
|
256
|
+
# Reset the size of the connection pool
|
257
|
+
def pool_size=(pool_size)
|
258
|
+
@gene_pool.pool_size = pool_size
|
259
|
+
end
|
260
|
+
|
261
|
+
# Return the size of the connection pool
|
262
|
+
def pool_size
|
263
|
+
@gene_pool.pool_size
|
264
|
+
end
|
265
|
+
|
249
266
|
##
|
250
267
|
# Makes a request per +req+. If +req+ is nil a Net::HTTP::Get is performed
|
251
268
|
# against +default_path+.
|
@@ -320,11 +337,8 @@ class PersistentHTTP
|
|
320
337
|
|
321
338
|
##
|
322
339
|
# Shuts down all connections.
|
323
|
-
|
324
|
-
|
325
|
-
raise 'Shutdown not implemented'
|
326
|
-
# TBD - need to think about this one
|
327
|
-
@count_hash = nil
|
340
|
+
def shutdown(timeout=10)
|
341
|
+
@gene_pool.close(timeout)
|
328
342
|
end
|
329
343
|
|
330
344
|
#######
|
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.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,19 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gene_pool
|
16
|
-
requirement: &
|
16
|
+
requirement: &70307428283760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.2.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70307428283760
|
25
25
|
description: Persistent HTTP connections using a connection pool
|
26
26
|
email:
|
27
27
|
- bradpardee@gmail.com
|
@@ -47,6 +47,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
47
|
- - ! '>='
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
hash: 1575083792056882891
|
50
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
54
|
none: false
|
52
55
|
requirements:
|