Module: OverSIP::Modules::Mysql
- Extended by:
- Logger
- Defined in:
- lib/oversip-mod-mysql.rb,
lib/oversip-mod-mysql/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
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/oversip-mod-mysql.rb', line 19 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 mysql2. 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 MySQL 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
39 40 41 42 43 |
# File 'lib/oversip-mod-mysql.rb', line 39 def self.pool pool_name pool = @pools[pool_name] raise ::ArgumentError, "no pool with `name' #{pool_name.inspect}" unless pool pool end |