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

Cache folder configuration for Azure and AWS Image Caches (Lombiq Technologies: OCORE-136) #353

Merged
merged 8 commits into from
Mar 6, 2024

Conversation

Piedone
Copy link
Contributor

@Piedone Piedone commented Jan 17, 2024

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

For multi-tenancy scenarios and for feature parity with PhysicalFileSystemCache, this PR adds a CacheFolder configuration for the Azure and AWS Image Caches

Please see #351 for more details, especially the rationale.

There are two things I'm unsure about, please advise:

  1. Tests: My usual approach in such cases would be to turn the test into a Theory with input parameters, and run the test once without setting CacheFolder, and then once with it. In this test suite, I don't really see how to approach this; I could add another class like AzureBlobStorageCacheTestServerFixture where the new property is set, but that seems like the wrong approach. Same for AWSS3StorageCacheTestServerFixture. What should I do? I've run the tests with the CacheFolders set and they still pass BTW.
  2. For AWS, I added the new property only to AWSS3StorageCacheOptions instead of also to IAWSS3BucketClientOptions, 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!

@CLAassistant
Copy link

CLAassistant commented Jan 17, 2024

CLA assistant check
All committers have signed the CLA.

Comment on lines +32 to +34
this.cacheFolder = string.IsNullOrEmpty(options.CacheFolder)
? string.Empty
: options.CacheFolder.Trim().Trim('/') + '/';
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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));
Copy link
Contributor Author

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()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored this.

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6096704) 85% compared to head (ff7fdc4) 85%.

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     
Flag Coverage Δ
unittests 85% <100%> (+<1%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a 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.

Comment on lines +32 to +34
this.cacheFolder = string.IsNullOrEmpty(options.CacheFolder)
? string.Empty
: options.CacheFolder.Trim().Trim('/') + '/';
Copy link
Member

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!;
Copy link
Member

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?

Copy link
Contributor Author

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!;
Copy link
Member

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?

@Piedone
Copy link
Contributor Author

Piedone commented Feb 21, 2024

Could you check this out @JimBobSquarePants, please?

@JimBobSquarePants
Copy link
Member

Sorry, yep will do!

@Piedone
Copy link
Contributor Author

Piedone commented Feb 22, 2024

Thank you!

@Piedone Piedone changed the title Cache folder configuration for Azure and AWS Image Caches Cache folder configuration for Azure and AWS Image Caches (Lombiq Technologies: OCORE-136) Mar 1, 2024
Copy link
Member

@JimBobSquarePants JimBobSquarePants left a 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!

@JimBobSquarePants JimBobSquarePants merged commit a3f306c into SixLabors:main Mar 6, 2024
9 checks passed
@Piedone
Copy link
Contributor Author

Piedone commented Mar 6, 2024

Awesome! And thanks for the quick release!

renovate bot referenced this pull request in orso-co/Orso.Arpa.Api Mar 9, 2024
[![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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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 [@&#8203;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
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/SixLabors/ImageSharp.Web/pull/357](https://togithub.com/SixLabors/ImageSharp.Web/pull/357)

#### New Contributors

- [@&#8203;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>
renovate bot referenced this pull request in orso-co/Orso.Arpa.Api Mar 9, 2024
…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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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 [@&#8203;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
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/SixLabors/ImageSharp.Web/pull/357](https://togithub.com/SixLabors/ImageSharp.Web/pull/357)

#### New Contributors

- [@&#8203;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>
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.

3 participants