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

Add NullMediaFileStoreCache to avoid injecting IServiceProvider #15391

Closed
wants to merge 4 commits into from

Conversation

hishamco
Copy link
Member

Introduce a Null Object Pattern for IMediaFileStoreCache to avoid injecting IServiceProvider

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

I'd wait with this until #15276 is merged.

@MikeAlhayek
Copy link
Member

I'd wait with this until #15276 is merged.

I agree this will have to wait.

@hishamco what you did here is much better than what we have today. I am not a fan of the null pattern, can you think of a better way like using feature dependency instead?

@hishamco
Copy link
Member Author

I am not a fan of the null pattern

:)

We could use feature dependency as you said but this is useful for 3rd-party media providers

@MikeAlhayek
Copy link
Member

We could use feature dependency as you said but this is useful for 3rd-party media providers

How about following the providers pattern (used in email PR) here too?

@hishamco
Copy link
Member Author

I'm not sure if it's a good idea to use the Provider Model everywhere, that's why I'm suggesting Null Object Pattern

@MikeAlhayek
Copy link
Member

I'm not sure if it's a good idea to use the Provider Model everywhere, that's why I'm suggesting Null Object Pattern

I'm not sure if it's a good idea to use the Null Object Pattern everywhere, that's why I'm suggesting Provider Model. 🤣

@hishamco
Copy link
Member Author

No problem bro, let's hear the other's feedback

@hishamco
Copy link
Member Author

hishamco commented Mar 1, 2024

@Piedone can we have a look to this again

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

Did you test this with AWS and Azure Media?

As for the provider pattern: this PR is about addressing something that's more of an aesthetic issue and I imagine it's only a more serious problem in extreme cases (I certainly haven't encountered any, nor can imagine one, even after working a lot with Media feature set in the last two years or so). The fix prevents potential NREs and DI resolution exceptions and is fine for that IMO.

I don't see any necessity to add any further complexity and would advise anybody against it too. If you'd like to, feel free, of course, but due to this and because I don't see this as a high-priority problem, I won't be able to allocate time to collaborate on it.

{
_authorizationService = authorizationService;
// Resolve from service provider as the service will not be registered if configuration is invalid.
_mediaFileStoreCache = serviceProvider.GetService<IMediaFileStoreCache>();
Copy link
Member

Choose a reason for hiding this comment

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

The nullcheck below should be adjusted too.

@hishamco
Copy link
Member Author

hishamco commented Mar 1, 2024

@MikeAlhayek while @Piedone doesn't have much time on this, can we use the Null Object Pattern or any other approach instead if using IServiceProvider

@Piedone
Copy link
Member

Piedone commented Mar 23, 2024

So, any news here? After #15391 (comment) I'm OK to merge this but only if as mentioned under #15391 (review) you confirm that you also tested it with both providers.

@hishamco
Copy link
Member Author

I can continue in this PR but my issue with testing with the underlying providers coz I didn't work with both Azure & S3 storage

@Piedone
Copy link
Member

Piedone commented Mar 23, 2024

Time to start now, then :).

@hishamco
Copy link
Member Author

While I don't have much experience with Azure & S3 storage media providers I might need to hand over this PR, or let someone to try it

@Piedone
Copy link
Member

Piedone commented Apr 15, 2024

Let's close this, then.

@Piedone Piedone closed this Apr 15, 2024
@hishamco
Copy link
Member Author

IMHO it's better to leave this open, so anyone can test if possible instead of not doing anything at all

@Piedone
Copy link
Member

Piedone commented Apr 15, 2024

In the last two months, nobody else came forward with an interest in this PR. What do we hope from keeping it open, and for how long?

@hishamco
Copy link
Member Author

While the PR change the pattern nothing related to the media itself, I hope to revise it in the upcoming month

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