diff --git a/go/mysql/binlog_event.go b/go/mysql/binlog_event.go index 27af9926c0c..5d472230d0e 100644 --- a/go/mysql/binlog_event.go +++ b/go/mysql/binlog_event.go @@ -91,6 +91,8 @@ type BinlogEvent interface { // Timestamp returns the timestamp from the event header. Timestamp() uint32 + // ServerID returns the server ID from the event header. + ServerID() uint32 // Format returns a BinlogFormat struct based on the event data. // This is only valid if IsFormatDescription() returns true. diff --git a/go/mysql/binlog_event_filepos.go b/go/mysql/binlog_event_filepos.go index 8a2976da80d..c71c8346964 100644 --- a/go/mysql/binlog_event_filepos.go +++ b/go/mysql/binlog_event_filepos.go @@ -211,6 +211,10 @@ func (ev filePosFakeEvent) Timestamp() uint32 { return ev.timestamp } +func (ev filePosFakeEvent) ServerID() uint32 { + return 1 +} + func (ev filePosFakeEvent) Format() (BinlogFormat, error) { return BinlogFormat{}, nil } diff --git a/go/mysql/binlog_event_make_test.go b/go/mysql/binlog_event_make_test.go index dddca2e0265..84535213cd9 100644 --- a/go/mysql/binlog_event_make_test.go +++ b/go/mysql/binlog_event_make_test.go @@ -374,6 +374,7 @@ func TestRowsEvent(t *testing.T) { require.True(t, reflect.DeepEqual(gotRows, rows), "NewRowsEvent().Rows() got Rows:\n%v\nexpected:\n%v", gotRows, rows) assert.NotZero(t, event.Timestamp()) + assert.NotZero(t, event.ServerID()) } func TestHeartbeatEvent(t *testing.T) { @@ -384,6 +385,7 @@ func TestHeartbeatEvent(t *testing.T) { require.NotNil(t, event) assert.True(t, event.IsHeartbeat()) assert.Zero(t, event.Timestamp()) + assert.NotZero(t, event.ServerID()) } func TestRotateRotateEvent(t *testing.T) {