コード例 #1
0
ファイル: proto3.go プロジェクト: pranjal5215/vitess
// 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
}
コード例 #2
0
ファイル: proto3.go プロジェクト: zhzhy917/vitess
// 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
}