func()

in datahub/implement.go [607:646]


func (datahub *DataHub) GetTupleRecords(projectName, topicName, shardId, cursor string, limit int, recordSchema *RecordSchema) (*GetRecordsResult, error) {
	if !util.CheckProjectName(projectName) {
		return nil, NewInvalidParameterErrorWithMessage(projectNameInvalid)
	}
	if !util.CheckTopicName(topicName) {
		return nil, NewInvalidParameterErrorWithMessage(topicNameInvalid)
	}
	if !util.CheckShardId(shardId) {
		return nil, NewInvalidParameterErrorWithMessage(shardIdInvalid)
	}
	if recordSchema == nil {
		return nil, NewInvalidParameterErrorWithMessage(missingRecordSchema)
	}

	path := fmt.Sprintf(shardPath, projectName, topicName, shardId)
	reqPara := &RequestParameter{
		Header: map[string]string{httpHeaderContentType: httpJsonContent},
	}
	grr := &GetRecordRequest{
		Action: "sub",
		Cursor: cursor,
		Limit:  limit,
	}
	respBody, commonResp, err := datahub.Client.Post(path, grr, reqPara)
	if err != nil {
		return nil, err
	}

	ret, err := NewGetRecordsResult(respBody, recordSchema, commonResp)
	if err != nil {
		return nil, err
	}

	for _, record := range ret.Records {
		if _, ok := record.(*TupleRecord); !ok {
			return nil, NewInvalidParameterErrorWithMessage("shouldn't call this method for BLOB topic")
		}
	}
	return ret, nil
}