hot_tub 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +4 -0
- data/README.md +12 -9
- data/lib/hot_tub/pool.rb +2 -2
- data/lib/hot_tub/reaper.rb +4 -0
- data/lib/hot_tub/sessions.rb +3 -3
- data/lib/hot_tub/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5663210c890daf049e5390ce2447e9249860fdf8
|
4
|
+
data.tar.gz: 8362b6b6d99650e71d8dc0a2202f05d474b6d893
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5dd46e1a804f0f91df47469b1d7b20b439e4719044c5ac6344e6f7d7248cd06a80866ca18978167b6d77f4e625d87364d84bcf7e44f8842ed7b26b020051b0c
|
7
|
+
data.tar.gz: 4f30786180f7138cfbaf8e4af4bb9dc32a2c45ee2ff1d371223a01c545b68556fea595af178200b6de5c883238e632adaeb04d99533244866d3acae029121272
|
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -69,9 +69,9 @@ A global Sessions object is available from the HotTub module and has several hel
|
|
69
69
|
# we are not setting :max_size so our connections will grow to match our currency.
|
70
70
|
# Once load dies down our pool will be reaped back down to 12 connections
|
71
71
|
|
72
|
-
|
73
|
-
HotTub.add(
|
74
|
-
uri = URI.parse(
|
72
|
+
URL = "https://google.com"
|
73
|
+
pool = HotTub.add(URL, { :size => 12 }) do
|
74
|
+
uri = URI.parse(URL)
|
75
75
|
http = Net::HTTP.new(uri.host, uri.port)
|
76
76
|
http.use_ssl = false
|
77
77
|
http.start
|
@@ -80,26 +80,29 @@ A global Sessions object is available from the HotTub module and has several hel
|
|
80
80
|
|
81
81
|
# A separate HotTub::Pool of Excon connections.
|
82
82
|
|
83
|
-
|
84
|
-
HotTub.add(url2, { :size => 5 }) { Excon.new }
|
83
|
+
HotTub.add('yahoo', { :size => 5 }) { Excon.new("https://yahoo.com") }
|
85
84
|
|
86
|
-
# Lets add Redis too.
|
85
|
+
# Lets add Redis too. HotTub.add returns the pool created for that key so we
|
86
|
+
# can store that in an constant for easy access.
|
87
87
|
# We don't want too many connections so we set our :max_size. Under load our pool
|
88
88
|
# can grow to 30 connections. Once load dies down our pool can be reaped back down to 5
|
89
89
|
|
90
|
-
HotTub.add("redis", :size => 5, :max_size => 30) { Redis.new }
|
90
|
+
REDIS = HotTub.add("redis", :size => 5, :max_size => 30) { Redis.new }
|
91
91
|
|
92
|
+
|
92
93
|
# Now we can call any of our pools using the key we set any where in our code.
|
93
94
|
|
94
95
|
HotTub.run(url) do |clnt|
|
95
96
|
puts clnt.head('/').code
|
96
97
|
end
|
97
98
|
|
98
|
-
HotTub.run(
|
99
|
+
HotTub.run('yahoo') do |clnt|
|
99
100
|
puts clnt.get(:path => "/some_stuff", :query => {:foo => 'bar'}).body
|
100
101
|
end
|
101
102
|
|
102
|
-
HotTub.
|
103
|
+
# Since our REDIS contast was set to HotTub::Pool instance return from HotTub.add
|
104
|
+
# we do not need the key when calling #run
|
105
|
+
REDIS.run do |clnt|
|
103
106
|
clnt.set('hot', 'stuff')
|
104
107
|
end
|
105
108
|
|
data/lib/hot_tub/pool.rb
CHANGED
@@ -112,7 +112,7 @@ module HotTub
|
|
112
112
|
|
113
113
|
@shutdown = false
|
114
114
|
@blocking_reap = (opts[:reaper] == false && !opts[:sessions])
|
115
|
-
@reaper =
|
115
|
+
@reaper = spawn_reaper unless (opts[:sessions] || (opts[:reaper] == false))
|
116
116
|
|
117
117
|
@never_block = (@max_size == 0)
|
118
118
|
|
@@ -171,7 +171,7 @@ module HotTub
|
|
171
171
|
end
|
172
172
|
if @reaper
|
173
173
|
kill_reaper
|
174
|
-
@reaper =
|
174
|
+
@reaper = spawn_reaper
|
175
175
|
end
|
176
176
|
ensure
|
177
177
|
@_out.clear
|
data/lib/hot_tub/reaper.rb
CHANGED
data/lib/hot_tub/sessions.rb
CHANGED
@@ -64,7 +64,7 @@ module HotTub
|
|
64
64
|
pool_options[:sessions] = true
|
65
65
|
pool_options[:name] = "#{@name} - #{key}"
|
66
66
|
@mutex.synchronize do
|
67
|
-
@reaper ||=
|
67
|
+
@reaper ||= spawn_reaper if @reaper.nil?
|
68
68
|
pool = @_sessions[key] ||= HotTub::Pool.new(pool_options, &client_block) unless @shutdown
|
69
69
|
end
|
70
70
|
pool
|
@@ -93,8 +93,8 @@ module HotTub
|
|
93
93
|
|
94
94
|
alias :[] :fetch
|
95
95
|
|
96
|
-
def run(
|
97
|
-
pool = fetch(
|
96
|
+
def run(key, &run_block)
|
97
|
+
pool = fetch(key)
|
98
98
|
pool.run &run_block
|
99
99
|
end
|
100
100
|
|
data/lib/hot_tub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot_tub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Mckinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
152
|
rubyforge_project: hot_tub
|
153
|
-
rubygems_version: 2.4.
|
153
|
+
rubygems_version: 2.4.5.1
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: Flexible connection pooling for Ruby.
|