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

Activity Infrastructure: Refactor the payloads and split the rules and creators #3382

Closed
wants to merge 1 commit into from

Conversation

CTMBNara
Copy link
Collaborator

Main goals:

  • Provide convenient way to create flexible payloads.
// before: As the payload expands, we will need to add new classes/add behavior to several old ones.
PrivacyEnforcementServiceActivityInvocationPayload.of(
                ActivityInvocationPayloadImpl.of(ComponentType.BIDDER, bidder),
                geo != null ? geo.getCountry() : null,
                geo != null ? geo.getRegion() : null,
                Optional.ofNullable(bidRequest.getRegs())
                        .map(Regs::getExt)
                        .map(ExtRegs::getGpc)
                        .orElse(null))
                        
                        
// now: As the payload expands, we will need to add new builder method.
ActivityInvocationPayload.builder()
                .component(ComponentType.BIDDER, bidder)
                .geo(geo != null ? geo.getCountry() : null, geo != null ? geo.getRegion() : null)
                .gpc(Optional.ofNullable(bidRequest.getRegs())
                        .map(Regs::getExt)
                        .map(ExtRegs::getGpc)
                        .orElse(null))
                .build();
  • Split the rules and rule creators. This will make future development easier.

Comment on lines +48 to +53
private static void validatePayloadType(ActivityInvocationPayload activityInvocationPayload) {
if (!(activityInvocationPayload instanceof CompositeActivityInvocationPayload)) {
throw new IllegalArgumentException(
"Invalid payload type. Please, consider to use 'ActivityPayload.builder()'.");
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can get rid of this invariant check. Instead of ActivityPayload.builder() we can implement ActivityPayload.forComponent(ComponentType componentType, String componentName)

@Compile-Ninja
Copy link
Collaborator

Discussed with team, we don't need this update for now

@Compile-Ninja Compile-Ninja deleted the activity-infrastructure/refactor-payloads branch September 23, 2024 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants