Module: Semian::Mysql2
- Includes:
- Adapter
- Defined in:
- lib/semian/mysql2.rb
Constant Summary collapse
- CONNECTION_ERROR =
Regexp.union( /Can't connect to MySQL server on/i, /Lost connection to MySQL server during query/i, /MySQL server has gone away/i, )
- ResourceBusyError =
::Mysql2::ResourceBusyError
- CircuitOpenError =
::Mysql2::CircuitOpenError
- DEFAULT_HOST =
'localhost'
- DEFAULT_PORT =
3306
- QUERY_WHITELIST =
Regexp.union( /\A\s*ROLLBACK/i, /\A\s*COMMIT/i, /\A\s*RELEASE\s+SAVEPOINT/i, )
Class Method Summary collapse
-
.included(base) ⇒ Object
The naked methods are exposed as ‘raw_query` and `raw_connect` for instrumentation purpose.
Instance Method Summary collapse
Methods included from Adapter
Class Method Details
.included(base) ⇒ Object
The naked methods are exposed as ‘raw_query` and `raw_connect` for instrumentation purpose
41 42 43 44 45 46 47 |
# File 'lib/semian/mysql2.rb', line 41 def self.included(base) base.send(:alias_method, :raw_query, :query) base.send(:remove_method, :query) base.send(:alias_method, :raw_connect, :connect) base.send(:remove_method, :connect) end |
Instance Method Details
#query(*args) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/semian/mysql2.rb', line 60 def query(*args) if query_whitelisted?(*args) raw_query(*args) else acquire_semian_resource(adapter: :mysql, scope: :query) { raw_query(*args) } end end |
#semian_identifier ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/semian/mysql2.rb', line 49 def semian_identifier @semian_identifier ||= begin unless name = && [:name] host = [:host] || DEFAULT_HOST port = [:port] || DEFAULT_PORT name = "#{host}:#{port}" end :"mysql_#{name}" end end |