feat: add getRemoteSize() to ImageService to enable customization of inferRemoteSize behavior
#15231
+73
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
As discussed in the issue #14515 and #15067, the current implementation of
inferRemoteSizehad the problem of increased network traffic because it did not cache data.To address this issue, I added a
getRemoteSizeproperty to the Image Service and implemented the publicly exposedinferRemoteSizeAPI to utilize this property.Additionally, for
baseService'sgetRemoteSize, I configured a function that simply wraps the existinginferRemoteSize. This ensures no breaking changes occur for users who do not wish to see their behavior altered.getRemoteSizeas an API of the Image Service.inferRemoteSizefunction to utilize the Image Service'sgetRemoteSize.inferRemoteSizefunction tobaseService'sgetRemoteSize. This prevents breaking changes and facilitates easy, lightweight extensions based on the existing implementation.Testing
I implemented tests to verify that arbitrary processing can be configured and that delegation from
baseServiceto the originalinferRemoteSizeis possible.Docs
Since we are setting the existing
inferRemoteSizeas the default value, I don't believe this constitutes a breaking change. However, since we will be introducing a new property calledgetRemoteSizein the Image Service, I think the documentation will need to be updated./cc @withastro/maintainers-docs
As this is a PR introducing a new property, I would like to hear the opinions of the maintainers regarding this approach. Therefore, I will submit this PR as a draft for now.