Class: EY::Snaplock::Database::MySQL

Inherits:
Object
  • Object
show all
Defined in:
lib/ey_snaplock/database/mysql.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ MySQL

Returns a new instance of MySQL.



5
6
7
# File 'lib/ey_snaplock/database/mysql.rb', line 5

def initialize(uri)
  @mysql = mysql_command(uri)
end

Instance Method Details

#with_lock(timeout) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/ey_snaplock/database/mysql.rb', line 9

def with_lock(timeout)
  aquire_lock_within_timeout(timeout)
  write_master_status(ENV["MASTER_STATUS_FILE"] || "/db/mysql/.snapshot_backup_master_status.txt")
  yield
rescue Timeout::Error
  lock_timeout(timeout)
ensure
  release_lock
end