diff --git a/reader/reader.go b/reader/reader.go index 85531c4..04da44c 100644 --- a/reader/reader.go +++ b/reader/reader.go @@ -35,6 +35,10 @@ func New(dsn string, sc slave.Config) (*Reader, error) { r := &Reader{ conn: conn, + state: binlog.Position{ + File: sc.File, + Offset: uint64(sc.Offset), + }, } r.initTableMap() @@ -131,6 +135,11 @@ func (r *Reader) ReadEvent() (*Event, error) { return &evt, err } +// State returns current position in the binary log. +func (r *Reader) State() binlog.Position { + return r.state +} + // Close underlying database connection. func (r *Reader) Close() error { return r.conn.Close()