Module: SeamlessDatabasePool::ConnectionStatistics
- Defined in:
- lib/seamless_database_pool/connection_statistics.rb
Overview
This module is included for testing. Mix it into each of your database pool connections and it will keep track of how often each connection calls update, insert, execute, or select.
Class Method Summary collapse
Instance Method Summary collapse
-
#connection_statistics ⇒ Object
Get the connection statistics.
- #execute_with_connection_statistics(sql, name = nil) ⇒ Object
- #insert_with_connection_statistics(sql, name = nil) ⇒ Object
- #reset_connection_statistics ⇒ Object
- #update_with_connection_statistics(sql, name = nil) ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/seamless_database_pool/connection_statistics.rb', line 6 def self.included(base) base.alias_method_chain(:update, :connection_statistics) base.alias_method_chain(:insert, :connection_statistics) base.alias_method_chain(:execute, :connection_statistics) base.alias_method_chain(:select, :connection_statistics) end |
Instance Method Details
#connection_statistics ⇒ Object
Get the connection statistics
14 15 16 |
# File 'lib/seamless_database_pool/connection_statistics.rb', line 14 def connection_statistics @connection_statistics ||= {} end |
#execute_with_connection_statistics(sql, name = nil) ⇒ Object
34 35 36 37 38 |
# File 'lib/seamless_database_pool/connection_statistics.rb', line 34 def execute_with_connection_statistics(sql, name = nil) increment_connection_statistic(:execute) do execute_without_connection_statistics(sql, name) end end |
#insert_with_connection_statistics(sql, name = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/seamless_database_pool/connection_statistics.rb', line 28 def insert_with_connection_statistics(sql, name = nil) increment_connection_statistic(:insert) do insert_without_connection_statistics(sql, name) end end |
#reset_connection_statistics ⇒ Object
18 19 20 |
# File 'lib/seamless_database_pool/connection_statistics.rb', line 18 def reset_connection_statistics @connection_statistics = {} end |
#update_with_connection_statistics(sql, name = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/seamless_database_pool/connection_statistics.rb', line 22 def update_with_connection_statistics(sql, name = nil) increment_connection_statistic(:update) do update_without_connection_statistics(sql, name) end end |