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(notifier): new notification pattern #326

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

e11sy
Copy link
Contributor

@e11sy e11sy commented Dec 8, 2024

This pr is a part of the new notification system

check full design of this feature in figma file

What is new

  • Now on worker side we will have critical and noncritical events (users would not know about terminology)

  • Event rule would be formed as:
    image

  • threshold, same as eventThresholdPeriod would be determined in garage by user in rule confuguration

What is notifications threshold?

Notifications threshold is a new term.

  • If event will reach threshold repetitions in eventTresholdPeriod, than event is critical and should be sent imidiately

Implemented

  • New redisHelper class for storing of the digest and project thresholds
  • New validation methods, to check if event is critical or not (old validation method related to rules remains)
  • Update redis dependencie
  • Get rid of buffer to set timers and store events (now we are using redis as a storage)
  • Remove unnecessary checks from validator
  • Set up redis testcontainer instead of redis-mock lib
  • Rewrite tests
  • Clean up

e11sy added 5 commits December 8, 2024 20:09
- added redis helper class and some methods for digest and threshold storing
- added env.sample for redis connections
- added dependencies related to redis
- add notifier method to get threshold from redis or from db
- add notifier method to check if event is critical
- updated lock
- get rid of the buffer
- move types to types directory
- improve old comments
@e11sy e11sy marked this pull request as ready for review December 11, 2024 17:51
// return 1 if period has been reset
return 1
else
local newCounter = redis.call("HINCRBY", key, "counter", 1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
local newCounter = redis.call("HINCRBY", key, "counter", 1)
local newCounter = redis.call("HINCRBY", key, "eventsCount", 1)

to support "usersCount" in a future

Copy link
Member

@slaveeks slaveeks left a comment

Choose a reason for hiding this comment

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

Cool! I think, it will be good to move types packages to devDependencies

@e11sy e11sy changed the title Feat (notifier-worker): new notification pattern Feat [ notifier ]: new notification pattern Dec 25, 2024
return newCounter
`;

const key = `${ruleId}:${groupHash}:${thresholdPeriod}:times`;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const key = `${ruleId}:${groupHash}:${thresholdPeriod}:times`;
const key = `${ruleId}:${groupHash}:${thresholdPeriod}`;

return newCounter
`;

const key = `${ruleId}:${groupHash}:${thresholdPeriod}:times`;
Copy link
Member

Choose a reason for hiding this comment

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

key should also include workspace id and project id

`${workspaceId}:${projectId}:${ruleId}:${groupHash}:${thresholdPeriod}`

});
for (const rule of rules) {
/**
* If rule is enabled no need to store data in redis
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* If rule is enabled no need to store data in redis
* If rule is disabled no need to store data in redis

@@ -130,10 +128,10 @@ export default class NotifierWorker extends Worker {
* @param {Rule} rule - notification rule
* @param {NotifierEvent} event - received event
*/
private addEventToChannels(projectId: string, rule: Rule, event: NotifierEvent): void {
private async addEventToChannels(projectId: string, rule: Rule, event: NotifierEvent): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private async addEventToChannels(projectId: string, rule: Rule, event: NotifierEvent): Promise<void> {
private async sendEventToChannels(projectId: string, rule: Rule, event: NotifierEvent): Promise<void> {

Copy link
Member

Choose a reason for hiding this comment

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

and update docs of this method

@e11sy e11sy changed the title Feat [ notifier ]: new notification pattern feat(notifier): new notification pattern Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants