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

Adding AsyncCollection<T> for Storage enumeration #6767

Merged
merged 15 commits into from
Jul 3, 2019

Conversation

tg-msft
Copy link
Member

@tg-msft tg-msft commented Jul 1, 2019

(Please only look at the latest commit.)

/// iterate over.
/// </summary>
/// <typeparam name="T">The type of the values.</typeparam>
public abstract class AsyncCollection<T> : IAsyncEnumerable<Response<T>>, IEnumerable<Response<T>>
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we need IEnumerable<Response> on this type at all. I can be implemented on StorageAsyncCollection

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we want this on the main public type. Even if it's implemented explicitly, customers should be able to see it's supported.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's an easy way to slip into sync codepath even after calling an async client method.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a fair point - Enumerable extension methods are going to make this pretty easy for people to mess up. What are your thoughts @KrzysztofCwalina?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changing to hide the implementation of IEnumerable<T> which is a better bet until we decide on the Sync half of the story, as discussed.

/// Initializes a new instance of the <see cref="AsyncCollection{T}"/>
/// class for mocking.
/// </summary>
protected AsyncCollection() =>
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit: Let's remove this ctor. Everyone should have a cancellation token when creating instances of this type.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want this even for mocking?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, I wonder if people would want to implement this as a mock, maybe we should just give them static factory methods.

AsyncCollection.Create(Response<T>[])
AsyncCollection.Create(Page<T>[])

Copy link
Contributor

@pakrym pakrym left a comment

Choose a reason for hiding this comment

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

Nice!

{
// TODO: Should this be Items instead of Values?
// - Probably not with Response.Values
// TODO: Should it be IEnumerable<T>?
Copy link
Contributor

Choose a reason for hiding this comment

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

Or ReadOnlyMemory

@tg-msft tg-msft force-pushed the async-coll branch 2 times, most recently from 147e37b to 89ff649 Compare July 1, 2019 22:13
Copy link
Contributor

@kfarmer-msft kfarmer-msft left a comment

Choose a reason for hiding this comment

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

The general pattern looks okay, but I have some serious naming concerns with the type itself.

sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs Outdated Show resolved Hide resolved
public virtual Response<BlobsFlatSegment> ListBlobsFlatSegment(
string marker = default,
BlobsSegmentOptions? options = default,
public virtual IEnumerable<Response<BlobItem>> GetBlobs(
Copy link
Member

Choose a reason for hiding this comment

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

I think we should return a concrete type, as we talked. But then, we need a name for it, i.e. we probably cannot return Collection (for one, it's not readonly). Let's think about it after preview 1.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, agreed.

/// <see cref="BlobContainerClient.GetBlobsByHierarchyAsync"/>
/// operations.
/// </summary>
public struct GetBlobsOptions : IEquatable<GetBlobsOptions>
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a big struct and it's mutable. Maybe we should change it to a class.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not that big once we remove PageSizeHint. It gets even smaller if we change the booleans to be a [Flags] enum.

/// or previous <see cref="Specialized.BlobClient.StartCopyFromUriAsync"/>
/// operation should be included.
/// </summary>
public bool IncludeCopyMetadata { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Should all these booleans just be a flags enum property? Just like in ConfigurationcLient APIs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's reasonable and I'll change it if we add a guideline.

sdk/storage/Azure.Storage.Common/src/AsyncCollection.cs Outdated Show resolved Hide resolved
sdk/storage/Azure.Storage.Common/src/AsyncCollection.cs Outdated Show resolved Hide resolved
sdk/storage/Azure.Storage.Common/src/AsyncCollection.cs Outdated Show resolved Hide resolved
tg-msft added 14 commits July 3, 2019 06:25
- Move shared code into folders
- Remove unused constants
- Remove IStorageCredentials interface
- Remove old TokenCredentials
- Rename SharedKey => StorageSharedKey
- Move PipelinePolicy into .Common
- Switch Tests to the Identity library
- Move HttpRange into Common
- Rename ID to Id
- Rename cancellation to cancellationToken
- Move access conditions into .Models
- Move remaining options into .Models
- Change Enqueue to return a single item instead of an array
- Move MessagesClient and MessageIdClient into QueueClient
- Add DequeuedMessage.Update helper
We're temporarily ignoring an issue with the auto-sync testing generated proxy Azure#6716
@tg-msft tg-msft merged commit c235cc3 into Azure:master Jul 3, 2019
@tg-msft tg-msft deleted the async-coll branch July 9, 2019 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants