diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-30 15:27:41 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-30 15:27:41 -0800 |
commit | 41c24eb3e38af99b208c17041199832a0372da8f (patch) | |
tree | 708576ff7cdbee5e70d10d90775abd3f7c3b0888 /activerecord/lib | |
parent | cde7692d4e3e0e67e480cc6172f6e2bacaceeb5e (diff) | |
download | rails-41c24eb3e38af99b208c17041199832a0372da8f.tar.gz rails-41c24eb3e38af99b208c17041199832a0372da8f.tar.bz2 rails-41c24eb3e38af99b208c17041199832a0372da8f.zip |
each connection pool has a reaper
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/connection_specification.rb | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index a26c435dad..f5c2c4f339 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -64,6 +64,9 @@ module ActiveRecord # * +wait_timeout+: number of seconds to block and wait for a connection # before giving up and raising a timeout error (default 5 seconds). class ConnectionPool + # Every +frequency+ seconds, the reaper will call +reap+ on +pool+. + # A reaper instantiated with a nil frequency will never reap the + # connection pool. class Reaper attr_reader :pool, :frequency @@ -86,7 +89,7 @@ module ActiveRecord include MonitorMixin attr_accessor :automatic_reconnect, :timeout - attr_reader :spec, :connections, :size + attr_reader :spec, :connections, :size, :reaper # Creates a new ConnectionPool object. +spec+ is a ConnectionSpecification # object which describes database connection information (e.g. adapter, @@ -103,6 +106,7 @@ module ActiveRecord @reserved_connections = {} @timeout = spec.config[:wait_timeout] || 5 + @reaper = Reaper.new self, spec.config[:reaping_frequency] # default max pool size to 5 @size = (spec.config[:pool] && spec.config[:pool].to_i) || 5 diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb index 3e67c3a2b7..34bdcc0802 100644 --- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb @@ -3,7 +3,7 @@ module ActiveRecord class ConnectionSpecification #:nodoc: attr_reader :config, :adapter_method - def initialize (config, adapter_method) + def initialize(config, adapter_method) @config, @adapter_method = config, adapter_method end |