-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
- 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
workers/notifier/src/redisHelper.ts
Outdated
// return 1 if period has been reset | ||
return 1 | ||
else | ||
local newCounter = redis.call("HINCRBY", key, "counter", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local newCounter = redis.call("HINCRBY", key, "counter", 1) | |
local newCounter = redis.call("HINCRBY", key, "eventsCount", 1) |
to support "usersCount" in a future
There was a problem hiding this 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
return newCounter | ||
`; | ||
|
||
const key = `${ruleId}:${groupHash}:${thresholdPeriod}:times`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const key = `${ruleId}:${groupHash}:${thresholdPeriod}:times`; | |
const key = `${ruleId}:${groupHash}:${thresholdPeriod}`; |
return newCounter | ||
`; | ||
|
||
const key = `${ruleId}:${groupHash}:${thresholdPeriod}:times`; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private async addEventToChannels(projectId: string, rule: Rule, event: NotifierEvent): Promise<void> { | |
private async sendEventToChannels(projectId: string, rule: Rule, event: NotifierEvent): Promise<void> { |
There was a problem hiding this comment.
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
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
andnoncritical
events (users would not know about terminology)Event rule would be formed as:
threshold
, same aseventThresholdPeriod
would be determined in garage by user in rule confugurationWhat is notifications
threshold
?Notifications
threshold
is a new term.threshold
repetitions ineventTresholdPeriod
, than event is critical and should be sent imidiatelyImplemented
redisHelper
class for storing of the digest and project thresholdsrules
remains)redis-mock
lib