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
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
36 37 38 39 40 41 42 |
# File 'lib/semian/mysql2.rb', line 36 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
55 56 57 |
# File 'lib/semian/mysql2.rb', line 55 def query(*args) acquire_semian_resource(adapter: :mysql, scope: :query) { raw_query(*args) } end |
#semian_identifier ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/semian/mysql2.rb', line 44 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 |