// ProtoToBinlogTransaction converts a proto to a BinlogTransaction func ProtoToBinlogTransaction(bt *pb.BinlogTransaction) *BinlogTransaction { result := &BinlogTransaction{ Timestamp: bt.Timestamp, GTIDField: myproto.GTIDField{ Value: myproto.MustDecodeGTID(bt.Gtid), }, } if len(bt.Statements) > 0 { result.Statements = make([]Statement, len(bt.Statements)) for i, s := range bt.Statements { result.Statements[i] = ProtoToStatement(s) } } return result }
// ProtoToStreamEvent converts a proto to a StreamEvent func ProtoToStreamEvent(s *pb.StreamEvent) *StreamEvent { result := &StreamEvent{ TableName: s.TableName, PrimaryKeyFields: mproto.Proto3ToFields(s.PrimaryKeyFields), PrimaryKeyValues: mproto.Proto3ToRows(s.PrimaryKeyValues), Sql: s.Sql, Timestamp: s.Timestamp, GTIDField: myproto.GTIDField{ Value: myproto.MustDecodeGTID(s.Gtid), }, } switch s.Category { case pb.StreamEvent_SE_DML: result.Category = "DML" case pb.StreamEvent_SE_DDL: result.Category = "DDL" case pb.StreamEvent_SE_POS: result.Category = "POS" default: result.Category = "ERR" } return result }