Class: CommonPool::Configuration
- Inherits:
-
Object
- Object
- CommonPool::Configuration
- Defined in:
- lib/common_pool.rb
Overview
Pool configuration.
Instance Attribute Summary collapse
-
#data_source ⇒ Object
The data source object to be extended, code>create_object</code> method need to be overridden.
-
#idle_check_interval ⇒ Object
Eviction thread interval in seconds.
-
#idle_check_no_per_run ⇒ Object
Number of objects to check per eviction thread run.
-
#logger ⇒ Object
Assign a logger, to log pool debug/info messages, used this for debugging purpose.
-
#max_active ⇒ Object
Maximum number of active objects in the pool.
-
#max_idle ⇒ Object
Maximum number of idle objects in the pool.
-
#max_idle_time ⇒ Object
Maximum idle time in seconds, before an object can be evicted.
-
#min_idle ⇒ Object
Minimum number of idle objects in the pool.
-
#timeout ⇒ Object
Request timeout when creating object for the pool, timeout in seconds.
-
#validation_timeout ⇒ Object
Request timeout when validation idle object in the pool, timeout in seconds.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Initilize configuration with default settings.
-
#to_hash ⇒ Object
Convert configuration properties to hash object.
Constructor Details
#initialize ⇒ Configuration
Initilize configuration with default settings.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/common_pool.rb', line 69 def initialize self.min_idle = 0 self.max_idle = 8 self.max_idle_time = 30 * 60 self.max_active = 8 self.idle_check_no_per_run = 3 self.idle_check_interval= 0 self.timeout = 60 self.validation_timeout = 30 end |
Instance Attribute Details
#data_source ⇒ Object
The data source object to be extended, code>create_object</code> method need to be overridden
66 67 68 |
# File 'lib/common_pool.rb', line 66 def data_source @data_source end |
#idle_check_interval ⇒ Object
Eviction thread interval in seconds. Default: 0. If set to 0 or less, the eviction thread will not run.
59 60 61 |
# File 'lib/common_pool.rb', line 59 def idle_check_interval @idle_check_interval end |
#idle_check_no_per_run ⇒ Object
Number of objects to check per eviction thread run. Default: 3. If set to 0 or less, all idle objects will be checked.
55 56 57 |
# File 'lib/common_pool.rb', line 55 def idle_check_no_per_run @idle_check_no_per_run end |
#logger ⇒ Object
Assign a logger, to log pool debug/info messages, used this for debugging purpose.
62 63 64 |
# File 'lib/common_pool.rb', line 62 def logger @logger end |
#max_active ⇒ Object
Maximum number of active objects in the pool. Default: 8.
43 44 45 |
# File 'lib/common_pool.rb', line 43 def max_active @max_active end |
#max_idle ⇒ Object
Maximum number of idle objects in the pool. Default: 8.
37 38 39 |
# File 'lib/common_pool.rb', line 37 def max_idle @max_idle end |
#max_idle_time ⇒ Object
Maximum idle time in seconds, before an object can be evicted. Default: 1800.
40 41 42 |
# File 'lib/common_pool.rb', line 40 def max_idle_time @max_idle_time end |
#min_idle ⇒ Object
Minimum number of idle objects in the pool. Default: 0.
34 35 36 |
# File 'lib/common_pool.rb', line 34 def min_idle @min_idle end |
#timeout ⇒ Object
Request timeout when creating object for the pool, timeout in seconds. Default: 60. If set to 0 or less, there will be no timeout.
47 48 49 |
# File 'lib/common_pool.rb', line 47 def timeout @timeout end |
#validation_timeout ⇒ Object
Request timeout when validation idle object in the pool, timeout in seconds. Default: 30. If set to 0 or less, there will be no timeout.
51 52 53 |
# File 'lib/common_pool.rb', line 51 def validation_timeout @validation_timeout end |
Instance Method Details
#to_hash ⇒ Object
Convert configuration properties to hash object.
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/common_pool.rb', line 81 def to_hash { :timeout => self.timeout, :validation_tmeout => self.validation_timeout, :min_idle => self.min_idle, :max_idle => self.max_idle, :max_idle_time => self.max_idle_time, :max_active => self.max_active, :idle_check_no_per_run => self.idle_check_no_per_run, :idle_check_interval => self.idle_check_interval} end |