Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadMany API #2326

Closed
j82w opened this issue Mar 22, 2021 · 4 comments
Closed

ReadMany API #2326

j82w opened this issue Mar 22, 2021 · 4 comments
Labels
API_REVIEW discussion-wanted Need a discussion on an area feature-request New feature or request

Comments

@j82w
Copy link
Contributor

j82w commented Mar 22, 2021

This is port the ReadMany API implemented by Java SDK. This API allows users to efficiently read many items from the container. This can be done via query and/or batch currently but makes the process complex and is not user friendly.

Suggested APIs

1. Single page response

Pros: It's easier to use. No complex pulling model. No users forgetting to do the HasMoreResult loop.
Cons: Stream response would need a way to join streams from multiple responses.

class Container
{
     public FeedResponse<T> ReadManyAsync(
          IReadonlyList<(string, PartitionKey)> items,
          RequestOptions requestOptions,
          CancellationToken cancellationToken);

     public ResponseMessage ReadManyStreamAsync(
          IReadonlyList<(string, PartitionKey)> items,
          RequestOptions requestOptions,
          CancellationToken cancellationToken);
}

2. Multiple page responses

Pros: Follows the same model as query and other multiple page responses
Cons: Requires users to combine the results from multiple pages and know to do the HasMoreResult to fully drain the results

class Container
{
     public FeedIterator<T> ReadManyAsync(
          IReadonlyList<(string, PartitionKey)> items,
          RequestOptions requestOptions,
          CancellationToken cancellationToken);

     public FeedIterator ReadManyStreamAsync(
          IReadonlyList<(string, PartitionKey)> items,
          RequestOptions requestOptions,
          CancellationToken cancellationToken);
}

Java PR: Azure/azure-sdk-for-java#8123

Implementation it will use Query under the covers to provide the functionality. This follows the current Java implementation.

@j82w j82w added discussion-wanted Need a discussion on an area API_REVIEW feature-request New feature or request labels Mar 22, 2021
@abhijitpai
Copy link
Contributor

Shouldn't this follow a FeedIterator based model to get paginated results if too many items are requested for?

@j82w
Copy link
Contributor Author

j82w commented Mar 25, 2021

@kirankumarkolli, @asketagarwal, @ealsur, @FabianMeiswinkel what are your opinions of the two models?

@asketagarwal
Copy link
Contributor

As per latest discussion, we have decided to go ahead with the first option (Single Page response) as we think it will be easier for our customers to use. We need to optimize on joining multiple stream responses.

class Container
{
     public FeedResponse<T> ReadManyAsync(
          IReadonlyList<(string, PartitionKey)> items,
          ReadManyRequestOptions requestOptions,
          CancellationToken cancellationToken);

     public ResponseMessage ReadManyStreamAsync(
          IReadonlyList<(string, PartitionKey)> items,
          ReadManyRequestOptions requestOptions,
          CancellationToken cancellationToken);
}

ReadManyRequestOptions is an overload of RequestOptions with sessiontoken and consistency options.

@j82w
Copy link
Contributor Author

j82w commented May 6, 2021

closed with #2352

@j82w j82w closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API_REVIEW discussion-wanted Need a discussion on an area feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants