func (p *BinlogParser) ParseSingleEvent(r io.Reader, onEvent OnEventFunc) (bool, error) {
	return p.parseSingleEvent(r, onEvent)
}
ParseSingleEvent parses single binlog event and passes the event to onEvent function.
package replication
import (
	"bytes"
	"encoding/binary"
	"fmt"
	"hash/crc32"
	"io"
	"os"
	"sync/atomic"
	"time"
	"github.com/juju/errors"
)
var (
	ErrChecksumMismatch = errors.New("binlog checksum mismatch, data may be corrupted")
)
type BinlogParser struct {
	format *FormatDescriptionEvent
	tables map[uint64]*TableMapEvent
	rawMode bool
	parseTime               bool
	timestampStringLocation *time.Location
	stopProcessing uint32
	useDecimal          bool
	ignoreJSONDecodeErr bool
	verifyChecksum      bool
}
func NewBinlogParser() *BinlogParser {
	p := new(BinlogParser)
	p.tables = make(map[uint64]*TableMapEvent)
	return p
}
func (p *BinlogParser) Stop() {
	atomic.StoreUint32(&p.stopProcessing, 1)
}
func (p *BinlogParser) Resume() {
	atomic.StoreUint32(&p.stopProcessing, 0)
}
func (p *BinlogParser) Reset() {
	p.format = nil
}
type OnEventFunc func(*BinlogEvent) error
func (p *BinlogParser) ParseFile(name string, offset int64, onEvent OnEventFunc) error {
	f, err := os.Open(name)
	if err != nil {
		return errors.Trace(err)
	}
	defer f.Close()
	b := make([]byte, 4)
	if _, err = f.Read(b); err != nil {
		return errors.Trace(err)
	} else if !bytes.Equal(b, BinLogFileHeader) {
		return errors.Errorf("%s is not a valid binlog file, head 4 bytes must fe'bin' ", name)
	}
	if offset < 4 {
		offset = 4
	} else if offset > 4 {
		if _, err = f.Seek(4, os.SEEK_SET); err != nil {
			return errors.Errorf("seek %s to %d error %v", name, offset, err)
		}
		if err = p.parseFormatDescriptionEvent(f, onEvent); err != nil {
			return errors.Annotatef(err, "parse FormatDescriptionEvent")
		}
	}
	if _, err = f.Seek(offset, os.SEEK_SET); err != nil {
		return errors.Errorf("seek %s to %d error %v", name, offset, err)
	}
	return p.ParseReader(f, onEvent)
}
func (p *BinlogParser) parseFormatDescriptionEvent(r io.Reader, onEvent OnEventFunc) error {
	_, err := p.parseSingleEvent(r, onEvent)
	return err
}