summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/http_pool.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-11-11 12:45:50 -0800
committerLuke Kanies <luke@madstop.com>2008-11-11 12:53:38 -0800
commitcd09d6b90d3365d06e8e706aab3edbd8f568f1c9 (patch)
tree1ebc569b688e17d70882415e897387c9d75b9213 /lib/puppet/network/http_pool.rb
parent14af971bc618d665f481142934b2f612d503823c (diff)
downloadpuppet-cd09d6b90d3365d06e8e706aab3edbd8f568f1c9.tar.gz
puppet-cd09d6b90d3365d06e8e706aab3edbd8f568f1c9.tar.xz
puppet-cd09d6b90d3365d06e8e706aab3edbd8f568f1c9.zip
Refactoring the Cacher interface to always require attribute declaration.
Previously you could dynamically use cached values, but the new interface requires a single static declaration of the attribute: cached_attr(:myattr) { my_init_code() } This is cleaner, because it makes it easy to turn the code into an init method and generally makes the whole thing easier to think about. Most of this commit is going through the different classes that already using the Caching engine. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/network/http_pool.rb')
-rw-r--r--lib/puppet/network/http_pool.rb22
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb
index 4b371abe7..ee28a3116 100644
--- a/lib/puppet/network/http_pool.rb
+++ b/lib/puppet/network/http_pool.rb
@@ -6,7 +6,14 @@ module Puppet::Network; end
# Manage Net::HTTP instances for keep-alive.
module Puppet::Network::HttpPool
- extend Puppet::Util::Cacher
+ class << self
+ include Puppet::Util::Cacher
+ cached_attr(:ssl_host) { Puppet::SSL::Host.new }
+
+ private
+
+ cached_attr(:http_cache) { Hash.new }
+ end
# 2008/03/23
# LAK:WARNING: Enabling this has a high propability of
@@ -17,12 +24,6 @@ module Puppet::Network::HttpPool
HTTP_KEEP_ALIVE
end
- # Create an ssl host instance for getting certificate
- # information.
- def self.ssl_host
- attr_cache(:ssl_host) { Puppet::SSL::Host.new }
- end
-
# Clear our http cache, closing all connections.
def self.clear_http_instances
http_cache.each do |name, connection|
@@ -102,11 +103,4 @@ module Puppet::Network::HttpPool
return http
end
-
- private
-
- def self.http_cache
- # Default to an empty hash.
- attr_cache(:http) { Hash.new }
- end
end