Example #1
0
// TODO(djd): This function is ugly in its current context. Refactor.
func callNext(ctx context.Context, client *Client, req *pb.RunQueryRequest, resp *pb.RunQueryResponse, offset, limit int32) (*pb.RunQueryResponse, error) {
	if resp.GetBatch().EndCursor == nil {
		return nil, errors.New("datastore: internal error: server did not return a cursor")
	}
	q := req.GetQuery()
	q.StartCursor = resp.Batch.EndCursor
	q.Offset = offset
	if limit >= 0 {
		q.Limit = &wrapperspb.Int32Value{limit}
	}
	return client.client.RunQuery(ctx, req)
}