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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Blob Cache and Test refactor. #112

Merged
merged 10 commits into from
Sep 1, 2020

Conversation

JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 馃懏.
  • I have provided test coverage for my change (where applicable)

Description

This has grown arms and legs. Started off as a simple Azure Blob Storage cache implementation turned into a realization that we're loading up the cache stream for 304s and that all our integration tests are super janky once the perf jumped. (We were generating multiple server instances that were hitting the same cache file).

No breaking changes thankfully, old cache files containing no content length will simply be reprocessed and cached.

@codecov
Copy link

codecov bot commented Aug 30, 2020

Codecov Report

Merging #112 into master will increase coverage by 1.33%.
The diff coverage is 89.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #112      +/-   ##
==========================================
+ Coverage   82.67%   84.01%   +1.33%     
==========================================
  Files          44       47       +3     
  Lines        1068     1126      +58     
  Branches      157      161       +4     
==========================================
+ Hits          883      946      +63     
+ Misses        137      128       -9     
- Partials       48       52       +4     
Flag Coverage 螖
#unittests 84.01% <89.91%> (+1.33%) 猬嗭笍

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage 螖
.../Providers/AzureBlobStorageImageProviderOptions.cs 66.66% <酶> (酶)
...arp.Web/Caching/PhysicalFileSystemCacheResolver.cs 100.00% <酶> (酶)
src/ImageSharp.Web/ImageMetadata.cs 66.66% <45.45%> (+9.52%) 猬嗭笍
src/ImageSharp.Web/ImageCacheMetadata.cs 83.58% <85.36%> (+1.76%) 猬嗭笍
...b.Providers.Azure/Caching/AzureBlobStorageCache.cs 100.00% <100.00%> (酶)
...ders.Azure/Caching/AzureBlobStorageCacheOptions.cs 100.00% <100.00%> (酶)
...s.Azure/Resolvers/AzureBlobStorageCacheResolver.cs 100.00% <100.00%> (酶)
...s.Azure/Resolvers/AzureBlobStorageImageResolver.cs 100.00% <100.00%> (酶)
.../ImageSharp.Web/Caching/PhysicalFileSystemCache.cs 94.28% <100.00%> (酶)
...mageSharp.Web/Commands/Converters/EnumConverter.cs 84.61% <100.00%> (酶)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 3554640...c24006b. Read the comment docs.

@JimBobSquarePants JimBobSquarePants marked this pull request as ready for review August 30, 2020 21:11
@JimBobSquarePants JimBobSquarePants changed the title WIP - Azure Blob Cache and Test refactor. Azure Blob Cache and Test refactor. Aug 30, 2020
@JimBobSquarePants JimBobSquarePants requested a review from a team August 30, 2020 21:12
Copy link
Member

@tocsoft tocsoft left a comment

Choose a reason for hiding this comment

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

Generally looking good, only thing I have a question mark over is the behaviour in AzureBlobStorageCache and generally the way the blob container is managed.

AzureBlobStorageCacheOptions options = cacheOptions.Value;

this.container = new BlobContainerClient(options.ConnectionString, options.ContainerName);
this.container.CreateIfNotExistsAsync(PublicAccessType.None);
Copy link
Member

Choose a reason for hiding this comment

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

should we really be creating this if it doesn't exists? or should we require application to do this during setup, I see this the same as EF etc I wouldn't expect my ORM to create the database for me unless I configured it so. We should however error if it doesn't exist.

Also shouldn't really be doing potentially expensive operations inside the constructor. There should probably be a private BlobContainerClient GetClientAsync() that is called to get the client or set it up if it hasn't yet been instantiated.

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 could make it optional I suppose. This changes the behavior compared to the physical cache though and our own default behavior of creating directories when we save to a destination path.

That constructor is only called once, the cache is registered as a singleton.

Copy link
Member

Choose a reason for hiding this comment

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

I feel file system is different you aren't dealing with potentially expensive operations on a remote server, you are dealing with local resources and can assume that is fast.

I think my main issue is that we really shouldn't be being called async/remote APIs during construction.

Even having a static async factory method would be fine its just that network call in the middle of the constructor that bothers me the most.

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'll move it to a factory then attached to the cache and allow passing the view enum as well then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants