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

feat: [Destinations] Support Fragments #491

Merged
merged 5 commits into from
Jul 29, 2024
Merged

Conversation

MatKuhr
Copy link
Member

@MatKuhr MatKuhr commented Jul 5, 2024

Context

This PR enhances the Cloud SDK to support Destination Fragments.

Feature scope:

  • Retrieve destinations with fragments
  • Cache based on fragments

Definition of Done

@MatKuhr MatKuhr added the please review Request to review a pull request label Jul 5, 2024
if( fragmentName.isBlank() ) {
throw new IllegalArgumentException("Fragment name must not be empty");
}
// sanity check to enforce this is only ever set once
Copy link
Member Author

Choose a reason for hiding this comment

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

not ideal, but making it final leads to more ugly code elsewhere. I felt this is safe enough..

Copy link
Contributor

@newtork newtork Jul 5, 2024

Choose a reason for hiding this comment

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

Hmm.. all other methods create a new immutable object, leveraging the Wither API design pattern.

I would want to see and compare the "ugly code" first before going with this compromise.

Copy link
Member Author

Choose a reason for hiding this comment

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

making it immutable would mean we need to change every instantiation of this object. That would be quite some more places, you can find them via usages of the current with.. methods.

*/
@Beta
@Nonnull
public DestinationServiceOptionsAugmenter fragmentName( @Nonnull final String fragmentName )
Copy link
Member Author

Choose a reason for hiding this comment

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

Only one fragment can be given per request, thus String. Adding this here is the natural place IMO, but it also has the advantage that the fragment name is automatically part of the cache key 😉

Copy link
Contributor

@newtork newtork Jul 5, 2024

Choose a reason for hiding this comment

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

the advantage that the fragment name is automatically part of the cache key

... How? is it the DestinationOptions part of the cache key?
Or do you mean the resulting destination properties will have mixed in values, that qualify as cache-key anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

is it the DestinationOptions part of the cache key?

yes 👍🏻

@@ -28,6 +28,8 @@ final class DestinationRetrievalStrategy
@Nullable
@ToString.Exclude
private final String token;
@Nullable
Copy link
Member Author

Choose a reason for hiding this comment

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

maybe a bit questionable to use this class for holding the fragment, but the alternative I saw would be to change DestinationServiceAdapter.java:

  String getConfigurationAsJson(
        @Nonnull final String servicePath,
        @Nonnull final DestinationRetrievalStrategy strategy,
+       @Nullable final String fragment )

which would lead to > 100 test changes. Considering that fragment is somewhat similar to refresh token I felt it was fair enough to put it here 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's hope the cardinality remains 0..1 :)

@MatKuhr MatKuhr marked this pull request as ready for review July 5, 2024 12:05
@MatKuhr MatKuhr added the please merge Request to merge a pull request label Jul 5, 2024
Comment on lines -162 to +168
@Nullable final String refreshToken )
@Nullable final String refreshToken,
@Nullable final String fragmentName )
Copy link
Contributor

@newtork newtork Jul 5, 2024

Choose a reason for hiding this comment

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

(Comment/Question)

At what point will we consider a header list to wrap these optional features? 😁

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 guess one or two more 😄
With the tokens once class makes sense, because the three options are mutually exclusive.

But in theory, we might want to support e.g. $filter in the future, then it's probably worth to create a new, dedicated object

.warn(
"""
A fragment was requested while change detection caching is enabled.\
This is not recommended, as fragment-based destinations will effectively not be cached with this strategy.\
Copy link
Contributor

Choose a reason for hiding this comment

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

(Question)

Fragment-based destinations will effectively not be cached with this strategy

I don't really understand this. Isn't "fragment-based" destination just a regular destination?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, the destination + fragment != destination. Thus, if you do getAll you will get the properties without the fragment properties, so when performing change detection the destination will always appear to be changed.

Copy link
Contributor

@CharlesDuboisSAP CharlesDuboisSAP left a comment

Choose a reason for hiding this comment

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

Please take over my WiP pull request: Fragment Destinations are compatible with Change Detection

release_notes.md Show resolved Hide resolved
release_notes.md Outdated Show resolved Hide resolved
Co-authored-by: Alexander Dümont <[email protected]>
@newtork newtork merged commit e370185 into main Jul 29, 2024
14 checks passed
@newtork newtork deleted the feat/destination-fragments branch July 29, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
please merge Request to merge a pull request please review Request to review a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants