コード例 #1
0
ファイル: proto3.go プロジェクト: forndb/vitess
// StreamEventToProto converts a StreamEvent to a proto3
func StreamEventToProto(s *StreamEvent) (*pb.StreamEvent, error) {
	fields, err := mproto.FieldsToProto3(s.PrimaryKeyFields)
	if err != nil {
		return nil, err
	}
	result := &pb.StreamEvent{
		TableName:        s.TableName,
		PrimaryKeyFields: fields,
		PrimaryKeyValues: mproto.RowsToProto3(s.PrimaryKeyValues),
		Sql:              s.Sql,
		Timestamp:        s.Timestamp,
		TransactionId:    s.TransactionID,
	}
	switch s.Category {
	case "DML":
		result.Category = pb.StreamEvent_SE_DML
	case "DDL":
		result.Category = pb.StreamEvent_SE_DDL
	case "POS":
		result.Category = pb.StreamEvent_SE_POS
	default:
		result.Category = pb.StreamEvent_SE_ERR
	}
	return result, nil
}
コード例 #2
0
ファイル: proto3.go プロジェクト: zhzhy917/vitess
// StreamEventToProto converts a StreamEvent to a proto3
func StreamEventToProto(s *StreamEvent) *pb.StreamEvent {
	result := &pb.StreamEvent{
		TableName:        s.TableName,
		PrimaryKeyFields: mproto.FieldsToProto3(s.PrimaryKeyFields),
		PrimaryKeyValues: mproto.RowsToProto3(s.PrimaryKeyValues),
		Sql:              s.Sql,
		Timestamp:        s.Timestamp,
		Gtid:             myproto.EncodeGTID(s.GTIDField.Value),
	}
	switch s.Category {
	case "DML":
		result.Category = pb.StreamEvent_SE_DML
	case "DDL":
		result.Category = pb.StreamEvent_SE_DDL
	case "POS":
		result.Category = pb.StreamEvent_SE_POS
	default:
		result.Category = pb.StreamEvent_SE_ERR
	}
	return result
}