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

[Improve] Refactor the notification sending logic. #2180

Merged
merged 14 commits into from
Jul 4, 2024
Merged

[Improve] Refactor the notification sending logic. #2180

merged 14 commits into from
Jul 4, 2024

Conversation

crossoverJie
Copy link
Member

Refactor the notification sending logic.

I noticed that most of the AlertNotifyHandlers require the use of NoticeTemplate, so I directly filtered out the data with null templateId, making the code more concise.

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

  • I have added the necessary e2e tests and all cases have passed.

Copy link
Contributor

@yuluo-yx yuluo-yx left a comment

Choose a reason for hiding this comment

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

lgtm

matchNoticeRulesByAlert(alert).ifPresent(noticeRules -> {
noticeRules.forEach(rule -> {
workerPool.executeNotify(() -> {
rule.getReceiverId().stream().filter(receiverId -> rule.getTemplateId() != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

hi, the code logic here is to filter out cases where the template id is null, but before the template id was null it would go to use the default file notification template.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for the reminder. I adjusted the logic;
I moved the template query earlier so it can return exceptions faster, and the code can be more concise.

@tomsun28 tomsun28 added this to the 1.6.1 milestone Jul 4, 2024
@tomsun28 tomsun28 added the good first pull request Good for newcomers label Jul 4, 2024
Copy link
Contributor

@tomsun28 tomsun28 left a comment

Choose a reason for hiding this comment

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

lgtm👍

@tomsun28 tomsun28 merged commit 0699e89 into apache:master Jul 4, 2024
3 checks passed
@crossoverJie crossoverJie deleted the refator-send-nofity branch July 8, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

3 participants