class MysqlBinlog::BinlogStreamReader

Read a binary log from a stream dumped using the MysqlBinlogDump library to request a COM_BINLOG_DUMP from a MySQL server via the Mysql library.

Public Class Methods

new(connection, filename, position) click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 6
def initialize(connection, filename, position)
  require 'mysql_binlog_dump'
  @filename = nil
  @position = nil
  @packet_data = nil
  @packet_pos  = nil
  @connection = connection
  MysqlBinlogDump.binlog_dump(connection, filename, position)
end

Public Instance Methods

end?() click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 37
def end?
  false
end
filename() click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 21
def filename
  @filename
end
position() click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 25
def position
  @position
end
read(length) click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 55
def read(length)
  unless @packet_data
    read_packet
    return nil unless @packet_data
  end
  pos = @packet_pos
  @position   += length if @position
  @packet_pos += length
  @packet_data[pos...(pos+length)]
end
read_packet() click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 50
def read_packet
  @packet_data = MysqlBinlogDump.next_packet(@connection)
  @packet_pos  = 0
end
remaining(header) click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 41
def remaining(header)
  @packet_data.length - @packet_pos
end
rewind() click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 29
def rewind
  false
end
rotate(filename, position) click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 16
def rotate(filename, position)
  @filename = filename
  @position = position
end
skip(header) click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 45
def skip(header)
  @packet_data = nil
  @packet_pos  = nil
end
tell() click to toggle source
# File lib/mysql_binlog/reader/binlog_stream_reader.rb, line 33
def tell
  @packet_pos
end