-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Cache folder configuration for Azure and AWS Image Caches (Lombiq Technologies: OCORE-136) #353
Conversation
this.cacheFolder = string.IsNullOrEmpty(options.CacheFolder) | ||
? string.Empty | ||
: options.CacheFolder.Trim().Trim('/') + '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I DRY this into a helper class, not to copy it between the two cache implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave as is and keep them separate. They're two separate assemblies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK then.
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<IImageCacheResolver?> GetAsync(string key) | ||
{ | ||
BlobClient blob = this.container.GetBlobClient(key); | ||
BlobClient blob = this.container.GetBlobClient(this.GetBlobName(key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should instead perhaps the whole right side be a method, like GetBlob()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #353 +/- ##
===================================
Coverage 85% 85%
===================================
Files 82 82
Lines 2332 2343 +11
Branches 348 350 +2
===================================
+ Hits 1999 2012 +13
+ Misses 231 230 -1
+ Partials 102 101 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. Just some minor issues here.
Regarding tests, it's not easy to make the configuration optional. For now, spin up a new fixture.
this.cacheFolder = string.IsNullOrEmpty(options.CacheFolder) | ||
? string.Empty | ||
: options.CacheFolder.Trim().Trim('/') + '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave as is and keep them separate. They're two separate assemblies.
/// <summary> | ||
/// Gets or sets the cache folder's name that'll store cache files under the configured bucket. | ||
/// </summary> | ||
public string CacheFolder { get; set; } = null!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want this to be nullable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually do. I changed this for the Azure class too.
/// Must conform to Azure Blob Storage directory naming guidelines. | ||
/// <see href="https://learn.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#directory-names"/> | ||
/// </summary> | ||
public string CacheFolder { get; set; } = null!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want this to be nullable?
Could you check this out @JimBobSquarePants, please? |
Sorry, yep will do! |
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Thanks!
Awesome! And thanks for the quick release! |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [SixLabors.ImageSharp.Web](https://togithub.com/SixLabors/ImageSharp.Web) | `3.1.0` -> `3.1.1` | [![age](https://developer.mend.io/api/mc/badges/age/nuget/SixLabors.ImageSharp.Web/3.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/SixLabors.ImageSharp.Web/3.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/SixLabors.ImageSharp.Web/3.1.0/3.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/SixLabors.ImageSharp.Web/3.1.0/3.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>SixLabors/ImageSharp.Web (SixLabors.ImageSharp.Web)</summary> ### [`v3.1.1`](https://togithub.com/SixLabors/ImageSharp.Web/releases/tag/v3.1.1) #### What's Changed - Bump actions/setup-dotnet from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/346](https://togithub.com/SixLabors/ImageSharp.Web/pull/346) - Cache folder configuration for Azure and AWS Image Caches (Lombiq Technologies: OCORE-136) by [@​Piedone](https://togithub.com/Piedone) in [https://github.com/SixLabors/ImageSharp.Web/pull/353](https://togithub.com/SixLabors/ImageSharp.Web/pull/353) - Bump actions/cache from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/355](https://togithub.com/SixLabors/ImageSharp.Web/pull/355) - Bump NuGet/setup-nuget from 1 to 2 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/356](https://togithub.com/SixLabors/ImageSharp.Web/pull/356) - Bump SixLabors.ImageSharp from 3.1.0 to 3.1.3 in /src/ImageSharp.Web by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/358](https://togithub.com/SixLabors/ImageSharp.Web/pull/358) - Bump codecov/codecov-action from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/357](https://togithub.com/SixLabors/ImageSharp.Web/pull/357) #### New Contributors - [@​Piedone](https://togithub.com/Piedone) made their first contribution in [https://github.com/SixLabors/ImageSharp.Web/pull/353](https://togithub.com/SixLabors/ImageSharp.Web/pull/353) **Full Changelog**: SixLabors/ImageSharp.Web@v3.1.0...v3.1.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 10pm every weekday,every weekend,before 5am every weekday" in timezone Europe/Berlin, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/orso-co/Orso.Arpa.Api). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIzMC4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…904) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [SixLabors.ImageSharp.Web.Providers.Azure](https://togithub.com/SixLabors/ImageSharp.Web) | `3.1.0` -> `3.1.1` | [![age](https://developer.mend.io/api/mc/badges/age/nuget/SixLabors.ImageSharp.Web.Providers.Azure/3.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/SixLabors.ImageSharp.Web.Providers.Azure/3.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/SixLabors.ImageSharp.Web.Providers.Azure/3.1.0/3.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/SixLabors.ImageSharp.Web.Providers.Azure/3.1.0/3.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>SixLabors/ImageSharp.Web (SixLabors.ImageSharp.Web.Providers.Azure)</summary> ### [`v3.1.1`](https://togithub.com/SixLabors/ImageSharp.Web/releases/tag/v3.1.1) #### What's Changed - Bump actions/setup-dotnet from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/346](https://togithub.com/SixLabors/ImageSharp.Web/pull/346) - Cache folder configuration for Azure and AWS Image Caches (Lombiq Technologies: OCORE-136) by [@​Piedone](https://togithub.com/Piedone) in [https://github.com/SixLabors/ImageSharp.Web/pull/353](https://togithub.com/SixLabors/ImageSharp.Web/pull/353) - Bump actions/cache from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/355](https://togithub.com/SixLabors/ImageSharp.Web/pull/355) - Bump NuGet/setup-nuget from 1 to 2 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/356](https://togithub.com/SixLabors/ImageSharp.Web/pull/356) - Bump SixLabors.ImageSharp from 3.1.0 to 3.1.3 in /src/ImageSharp.Web by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/358](https://togithub.com/SixLabors/ImageSharp.Web/pull/358) - Bump codecov/codecov-action from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/SixLabors/ImageSharp.Web/pull/357](https://togithub.com/SixLabors/ImageSharp.Web/pull/357) #### New Contributors - [@​Piedone](https://togithub.com/Piedone) made their first contribution in [https://github.com/SixLabors/ImageSharp.Web/pull/353](https://togithub.com/SixLabors/ImageSharp.Web/pull/353) **Full Changelog**: SixLabors/ImageSharp.Web@v3.1.0...v3.1.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 10pm every weekday,every weekend,before 5am every weekday" in timezone Europe/Berlin, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/orso-co/Orso.Arpa.Api). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIzMC4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Prerequisites
Description
For multi-tenancy scenarios and for feature parity with
PhysicalFileSystemCache
, this PR adds aCacheFolder
configuration for the Azure and AWS Image CachesPlease see #351 for more details, especially the rationale.
There are two things I'm unsure about, please advise:
Theory
with input parameters, and run the test once without settingCacheFolder
, and then once with it. In this test suite, I don't really see how to approach this; I could add another class likeAzureBlobStorageCacheTestServerFixture
where the new property is set, but that seems like the wrong approach. Same forAWSS3StorageCacheTestServerFixture
. What should I do? I've run the tests with theCacheFolder
s set and they still pass BTW.AWSS3StorageCacheOptions
instead of also toIAWSS3BucketClientOptions
, since the scope of Ability to configure a folder (sub-path) for Azure Blob Storage and AWS S3 caches #351 is about caching only. Should I do anything differently?See the related docs PR: SixLabors/docs#65.
Thank you!