1
0
Fork 0

Expose reader state

This commit is contained in:
Gregory Eremin 2018-11-11 20:33:29 +01:00
parent ca74b866b6
commit 1308d3306a
1 changed files with 9 additions and 0 deletions

View File

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