Пример #1
0
// 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,
		TransactionID:    s.TransactionId,
	}
	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
}
Пример #2
0
// 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
}