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

[Storage] Async iterator for listing blobs and containers - storage-blob #3136

Merged

Conversation

HarshaNalluru
Copy link
Member

No description provided.

@HarshaNalluru HarshaNalluru self-assigned this May 23, 2019
@HarshaNalluru HarshaNalluru added Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files) labels May 23, 2019
@HarshaNalluru HarshaNalluru changed the title [Storage] Async iterator for container - listBlobs [Storage] Async iterator for listing blobs and containers May 23, 2019
Copy link
Member

@jeremymeng jeremymeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. some nit comments.

@HarshaNalluru HarshaNalluru changed the title [Storage] Async iterator for listing blobs and containers [Storage] Async iterator for listing blobs and containers - storage-blob May 23, 2019
* @memberof BlobServiceClient
*
* @example
* for await (const container of blobServiceClient.listContainers()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering what will happen if Aborter aborted iteration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example -

  // List containers - generator syntax
  let iter2 = await blobServiceClient.listContainers({ abortSignal: Aborter.timeout(X) });
  i = 1;
  let containerItem = await iter2.next();
  do {
    console.log(`Container ${i++}: ${containerItem.value.name}`);
    containerItem = await iter2.next();
  } while (containerItem.value);

[ About 6500 containers are present in the account ]

  • When X = 50000 (large number), all the 6500 containers got listed(and their names are printed in the terminal)
  • When X = 2000, only 5000 containers got listed and a message got printed saying The request was aborted.
    image
    [ X = 10000 yielded the same result ]
  • When X < 1000, none of the containers got listed, The request was aborted is printed in the terminal.

* } while (blobItem.value);
*
*/
public async *listBlobs(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or called listBlobsFlat to avoid confusing between flat and hierarchical listing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Member

@XiaoningLiu XiaoningLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test cases as well

@HarshaNalluru HarshaNalluru marked this pull request as ready for review May 28, 2019 23:50
blobClients.push(blobClient);
}

const iterator = await containerClient.listBlobsFlat({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need test against other usage scenarios for async iterator? such as async for loop

Copy link
Member

@XiaoningLiu XiaoningLiu May 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we cover the cross segment scenario? Because implementation of listBlobsFlat needs to handle marker update, while existing test case doesn't cover that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we cover the cross segment scenario? Because implementation of listBlobsFlat needs to handle marker update, while existing test case doesn't cover that

I'm not sure if we are doing it.

public async *listBlobsFlat(
options: ContainerListBlobsSegmentOptions = {}
): AsyncIterableIterator<Models.BlobItem> {
let marker = undefined;
const containerClient = this;

The current implementation of listBlobsFlat doesn't take marker as an input.
We can make marker as an optional attribute to the method. I'm just not sure if we want to do it.

Copy link
Member Author

@HarshaNalluru HarshaNalluru May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Sorry for the confusion.
  • After an offline discussion with Jeremy, he suggested that you might be referring to the usage of more than one listBlobFlatSegment in the same listBlobsFlat call.

842de33 - Added a for-loop test case.

Outputs (console.logs) to verify your question.
[By passing maxresults in the options for listBlobsFlat ]

Case 1 - maxresults is not set

------------------------- called listBlobFlatSegment -------------------------
blockblob/0155925458974007856
blockblob/1155925459003608508
blockblob/2155925459032203396
blockblob/3155925459061100420
    √ Verify AsyncIterator(for-loop syntax) for listBlobsFlat (2714ms)

Case 2 - maxresults is set to 2

------------------------- called listBlobFlatSegment -------------------------
blockblob/0155925451934305295
blockblob/1155925451964308353
------------------------- called listBlobFlatSegment -------------------------
blockblob/2155925451993002640
blockblob/3155925452022007968
    √ Verify AsyncIterator(for-loop syntax) for listBlobsFlat (3012ms)

@@ -222,7 +222,7 @@ describe("ContainerClient", () => {
}
});

it("Verify AsyncIterator for listBlobsFlat", async () => {
it("Verify AsyncIterator(generator .next() syntax) for listBlobsFlat", async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would the special characters ( and ) affect later record and playback test generation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they won't. We handled those things gracefully 😊

@HarshaNalluru HarshaNalluru merged commit 70de2aa into Azure:feature/storage May 31, 2019
@HarshaNalluru HarshaNalluru deleted the AsyncIteratorsStorageBlob branch May 31, 2019 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants