Module: ActiveRecord::ConnectionAdapters::MasterSlaveAdapter::SharedMysqlAdapterBehavior
- Defined in:
- lib/active_record/connection_adapters/master_slave_adapter/shared_mysql_adapter_behavior.rb
Instance Method Summary collapse
Instance Method Details
#master_clock ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/shared_mysql_adapter_behavior.rb', line 18 def master_clock conn = master_connection if status = conn.uncached { conn.select_one("SHOW MASTER STATUS") } Clock.new(status['File'], status['Position']) else Clock.infinity end rescue MasterUnavailable Clock.zero rescue ActiveRecordError Clock.infinity end |
#slave_clock(conn) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/shared_mysql_adapter_behavior.rb', line 31 def slave_clock(conn) if status = conn.uncached { conn.select_one("SHOW SLAVE STATUS") } Clock.new(status['Relay_Master_Log_File'], status['Exec_Master_Log_Pos']) else Clock.zero end rescue ActiveRecordError Clock.zero end |
#with_consistency(clock) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/shared_mysql_adapter_behavior.rb', line 7 def with_consistency(clock) clock = case clock when Clock then clock when String then Clock.parse(clock) when nil then Clock.zero end super(clock) end |