1
0
Fork 0
bocadillo/binlog/event_rotate.go

29 lines
725 B
Go
Raw Normal View History

package binlog
2018-11-06 22:17:48 +00:00
import "github.com/localhots/bocadillo/tools"
// Position ...
type Position struct {
File string
Offset uint64
}
// RotateEvent is written at the end of the file that points to the next file in
// the squence. It is written when a binary log file exceeds a size limit.
type RotateEvent struct {
NextFile Position
}
// Decode decodes given buffer into a rotate event.
// Spec: https://dev.mysql.com/doc/internals/en/rotate-event.html
func (e *RotateEvent) Decode(connBuff []byte, fd FormatDescription) error {
buf := tools.NewBuffer(connBuff)
if fd.Version > 1 {
e.NextFile.Offset = buf.ReadUint64()
} else {
e.NextFile.Offset = 4
}
e.NextFile.File = string(buf.ReadStringEOF())
return nil
}