Class: Db2Query::Connection
- Inherits:
-
Object
- Object
- Db2Query::Connection
- Includes:
- DbStatements, Logger
- Defined in:
- lib/db2_query/db_connection.rb
Defined Under Namespace
Classes: Pool
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#connection_pool ⇒ Object
readonly
Returns the value of attribute connection_pool.
-
#instrumenter ⇒ Object
readonly
Returns the value of attribute instrumenter.
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
Instance Method Summary collapse
- #create_connection_pool ⇒ Object
-
#initialize(config) ⇒ Connection
constructor
A new instance of Connection.
- #pool_config ⇒ Object
Methods included from DbStatements
#exec_query, #execute, #query, #query_rows, #query_value, #query_values, #raw_query, #reset_id_sequence!
Methods included from Logger
#log, #translate_exception, #translate_exception_class
Constructor Details
#initialize(config) ⇒ Connection
Returns a new instance of Connection.
46 47 48 49 50 51 52 |
# File 'lib/db2_query/db_connection.rb', line 46 def initialize(config) @config = config @instrumenter = ActiveSupport::Notifications.instrumenter @mutex = Mutex.new @connection_pool = nil create_connection_pool end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
38 39 40 |
# File 'lib/db2_query/db_connection.rb', line 38 def config @config end |
#connection_pool ⇒ Object (readonly)
Returns the value of attribute connection_pool.
38 39 40 |
# File 'lib/db2_query/db_connection.rb', line 38 def connection_pool @connection_pool end |
#instrumenter ⇒ Object (readonly)
Returns the value of attribute instrumenter.
38 39 40 |
# File 'lib/db2_query/db_connection.rb', line 38 def instrumenter @instrumenter end |
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
38 39 40 |
# File 'lib/db2_query/db_connection.rb', line 38 def mutex @mutex end |
Instance Method Details
#create_connection_pool ⇒ Object
60 61 62 63 64 65 |
# File 'lib/db2_query/db_connection.rb', line 60 def create_connection_pool mutex.synchronize do return @connection_pool if @connection_pool @connection_pool = Pool.new(pool_config) { DbClient.new(config) } end end |
#pool_config ⇒ Object
56 57 58 |
# File 'lib/db2_query/db_connection.rb', line 56 def pool_config { size: config[:pool], timeout: config[:timeout] } end |