Simplify rows event decoding
This commit is contained in:
parent
69353f61bc
commit
8cbca43cf7
|
@ -118,3 +118,12 @@ func (r *Reader) ReadEvent() (*Event, error) {
|
|||
|
||||
return &evt, err
|
||||
}
|
||||
|
||||
// DecodeRows decodes buffer into a rows event.
|
||||
func (e Event) DecodeRows() (binlog.RowsEvent, error) {
|
||||
re := binlog.RowsEvent{Type: e.Header.Type}
|
||||
if binlog.RowsEventVersion(e.Header.Type) < 0 {
|
||||
return re, errors.New("invalid rows event")
|
||||
}
|
||||
return re, re.Decode(e.Buffer, e.Format, *e.Table)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/localhots/bocadillo/binlog"
|
||||
"github.com/localhots/bocadillo/mysql"
|
||||
"github.com/localhots/bocadillo/reader"
|
||||
)
|
||||
|
@ -200,8 +199,7 @@ func (s *testSuite) expectValue(t *testing.T, tbl *table, exp interface{}) {
|
|||
return
|
||||
}
|
||||
if evt.Table != nil && evt.Table.TableName == tbl.name {
|
||||
re := binlog.RowsEvent{Type: evt.Header.Type}
|
||||
err := re.Decode(evt.Buffer, evt.Format, *evt.Table)
|
||||
re, err := evt.DecodeRows()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode rows event: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue