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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78df9f4441ecfb13b4eb6de670d8384c140c3b4d
4
- data.tar.gz: 345d9409cd6e30bbfff90bea8cc9bef734dbe062
3
+ metadata.gz: 5663210c890daf049e5390ce2447e9249860fdf8
4
+ data.tar.gz: 8362b6b6d99650e71d8dc0a2202f05d474b6d893
5
5
  SHA512:
6
- metadata.gz: 56004ba7b29c84e4633cdf22dd88701bd2ecfa02980e146cf2358bb4cf0f6fc6fd044d7df998359f4f3fcb3988f9583ef7b78121726b58fa31bf25a2ab9177ed
7
- data.tar.gz: c18c797037130388cdd8e3faa094b592702811364d726bac1ef5f0b57d4ef38576e0c504da8371b66864b6ca27cff80b3b7a16e0e8d749dc770be6deaed935b0
6
+ metadata.gz: a5dd46e1a804f0f91df47469b1d7b20b439e4719044c5ac6344e6f7d7248cd06a80866ca18978167b6d77f4e625d87364d84bcf7e44f8842ed7b26b020051b0c
7
+ data.tar.gz: 4f30786180f7138cfbaf8e4af4bb9dc32a2c45ee2ff1d371223a01c545b68556fea595af178200b6de5c883238e632adaeb04d99533244866d3acae029121272
data/HISTORY.md CHANGED
@@ -3,6 +3,10 @@ HotTub Changelog
3
3
 
4
4
  Head
5
5
  =======
6
+ - Add spawn_reaper to Reaper::Mixin.
7
+
8
+ 0.5.0
9
+ =======
6
10
  - Drop Thread::Safe dependency
7
11
  - Make Sessions useful, complete re-write and provide global sessions support
8
12
  - Refactor and clean up Pool
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
- url = "https://google.com"
73
- HotTub.add(url, { :size => 12 }) do
74
- uri = URI.parse(url)
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
- url2 = "http://someOtherServices.com"
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(url2) do |clnt|
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.run('redis') do |clnt|
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
 
@@ -112,7 +112,7 @@ module HotTub
112
112
 
113
113
  @shutdown = false
114
114
  @blocking_reap = (opts[:reaper] == false && !opts[:sessions])
115
- @reaper = Reaper.spawn(self) unless (opts[:sessions] || (opts[:reaper] == false))
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 = Reaper.spawn(self)
174
+ @reaper = spawn_reaper
175
175
  end
176
176
  ensure
177
177
  @_out.clear
@@ -53,6 +53,10 @@ module HotTub
53
53
  @reaper = nil
54
54
  end
55
55
  end
56
+
57
+ def spawn_reaper
58
+ Reaper.spawn(self)
59
+ end
56
60
  end
57
61
  end
58
62
  end
@@ -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 ||= Reaper.spawn(self) if @reaper.nil?
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(url, &run_block)
97
- pool = fetch(url)
96
+ def run(key, &run_block)
97
+ pool = fetch(key)
98
98
  pool.run &run_block
99
99
  end
100
100
 
@@ -1,3 +1,3 @@
1
1
  module HotTub
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
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.0
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-03 00:00:00.000000000 Z
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.8
153
+ rubygems_version: 2.4.5.1
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: Flexible connection pooling for Ruby.