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

NOTIF-315 Adds support for default behavior #809

Merged
merged 31 commits into from
Jan 10, 2022

Conversation

josejulio
Copy link
Member

@josejulio josejulio commented Nov 29, 2021

This PR adds a behavior group type that is not bound to an specifyc account_id. Instead it can be used globally across all accounts.

Default behavior group

The only considerated endpoint type for this kind of behavior groups is the EmailSubscription, and it needs to be global as well (account_id should be null).
There are new endpoints in the Internal API for managing this configuration:

  • POST /defaultBehaviorGroups (BehaviorGroup)
    • Creates a default behavior group
  • PUT /defaultBehaviorGroups/{behaviorGroupId}/actions (List of EmailSubscriptionProperties)
    • Updates the set of action of a default behavior group
  • PUT /defaultBehaviorGroups/{behaviorGroupId}/eventType/{eventTypeId}
    • Links a default behavior group to an event type
  • DELETE /defaultBehaviorGroups/{behaviorGroupId}/eventType/{eventTypeId}
    • Unlinks a default behavior group from an event type

Some remarks:

  • A new response-only attribute is dynamically set to the behavior group: default_behavior. It is true when the account_id is null, false otherwise.
  • This code also includes an utility (CommonStateSession) to easen the code when dealing with functions that could be used in both stateful and stateless. This could be potentially extracted as a separate PR to ease the review.

CommonStateSession

We use stateful sessions when dealing with REST calls and stateless sessions with kakfa events. There are some functions that we need in both places, instead of duplicating the function to run in both scenarios, a wrapper was created for a subset of operations.

The CommonStateSessionFactory provides a method to request a session depending our needs - The developer has to specify the state type, it doesn't autodetect anything.

Stateless sessions using this tool will attempt to mimic what one could expect with the stateful sessions. Currently it does use introspection to find if there is any method annotated with @PrePersit that should be called. This process is cached per class to avoid recomputing this on every call.

Copy link
Member

@gwenneg gwenneg left a comment

Choose a reason for hiding this comment

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

I only had a look at the sessions changes, this looks interesting!

@josejulio josejulio marked this pull request as ready for review December 15, 2021 18:22
@gwenneg gwenneg self-assigned this Dec 16, 2021
@pilhuhn pilhuhn mentioned this pull request Dec 21, 2021
Copy link
Member

@gwenneg gwenneg left a comment

Choose a reason for hiding this comment

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

FYI I will review the code again later, after most of the following comments have been resolved.

@gwenneg
Copy link
Member

gwenneg commented Dec 23, 2021

Sorry for the delay before I reviewed this BTW 😃

@josejulio
Copy link
Member Author

@gwenneg I addressed most of the suggested changes

@josejulio
Copy link
Member Author

Updated again!

Copy link
Member

@gwenneg gwenneg left a comment

Choose a reason for hiding this comment

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

I'm done reviewing the runtime code. I'll have a look at the test tomorrow.

josejulio and others added 7 commits January 7, 2022 08:55
Co-authored-by: Gwenneg Lepage <gwenneg@users.noreply.github.com>
…fecycleITest.java

Co-authored-by: Gwenneg Lepage <gwenneg@users.noreply.github.com>
…fecycleITest.java

Co-authored-by: Gwenneg Lepage <gwenneg@users.noreply.github.com>
Copy link
Member

@gwenneg gwenneg left a comment

Choose a reason for hiding this comment

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

LGTM

@gwenneg
Copy link
Member

gwenneg commented Jan 7, 2022

The PR check failures seem unrelated.

@josejulio josejulio merged commit d20d39f into RedHatInsights:master Jan 10, 2022
@josejulio josejulio deleted the NOTIF-315 branch January 10, 2022 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants