Module: OverSIP::Modules::Postgresql
- Extended by:
- Logger
- Defined in:
- lib/oversip-mod-postgresql.rb,
lib/oversip-mod-postgresql/version.rb
Defined Under Namespace
Modules: Version Classes: Pool
Constant Summary collapse
Class Method Summary collapse
- .add_pool(options) ⇒ Object
-
.pool(pool_name) ⇒ Object
(also: get_pool)
def self.add_pool.
Class Method Details
.add_pool(options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/oversip-mod-postgresql.rb', line 18 def self.add_pool raise ::ArgumentError, "`options' must be a Hash" unless .is_a? ::Hash # Avoid the hash to be modified internally. = .clone # Delete options not existing in pg. pool_name = .delete(:pool_name) pool_size = .delete(:pool_size) || DEFAULT_POOL_SIZE raise ::ArgumentError, "`options[:pool_name]' must be a Symbol" unless pool_name.is_a? ::Symbol raise ::ArgumentError, "`options[:pool_size]' must be a positive Fixnum" unless pool_size.is_a? ::Fixnum and pool_size > 0 block = ::Proc.new if block_given? ::OverSIP::SystemCallbacks.on_started do log_info "Adding PostgreSQL connection pool (name: #{pool_name.inspect}, size: #{pool_size})..." @pools[pool_name] = Pool.new pool_size, , block end end |
.pool(pool_name) ⇒ Object Also known as: get_pool
def self.add_pool
38 39 40 41 42 |
# File 'lib/oversip-mod-postgresql.rb', line 38 def self.pool pool_name pool = @pools[pool_name] raise ::ArgumentError, "no pool with `name' #{pool_name.inspect}" unless pool pool end |