Service - Notification Manager: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 8: | Line 8: | ||
https://bitbucket.org/izara-core-shared/izara-core-shared-notification-manager | https://bitbucket.org/izara-core-shared/izara-core-shared-notification-manager | ||
= Object Schemas = | = Object Schemas = | ||
| Line 31: | Line 17: | ||
=== notificationGroup === | === notificationGroup === | ||
* Groups many | * Groups many triggerGroups together | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
| Line 56: | Line 40: | ||
optionalOnCreate: true, // default = false | optionalOnCreate: true, // default = false | ||
canUpdate: true, // default = true | canUpdate: true, // default = true | ||
validation: { | validation: { | ||
pattern: pattern | pattern: pattern | ||
| Line 137: | Line 112: | ||
; notificationGroupId (identifier) | ; notificationGroupId (identifier) | ||
: comes from: | : comes from: hash{notifications} | ||
; notificationGroupName | ; notificationGroupName | ||
: string name set by reciever service, optional | : string name set by reciever service, optional | ||
; consolidated | ; consolidated (maybe remove and use '''consolidatedType''' for check consolidated ) | ||
: true|false | : true | false | ||
; consolidatedType | ; consolidatedType | ||
: overview|detailed | : overview | detailed | null | ||
: ''overview'' sends a count of each type of notification, ''detailed'' lists each activity message | : ''overview'' sends a count of each type of notification, ''detailed'' lists each activity message | ||
: ''null'' that mean notificationGroup is not consolidated and send to receiver service | |||
; consolidatedFrequency | ; consolidatedFrequency | ||
: not sure, maybe use some sort of standard like cron | : not sure, maybe use some sort of standard like cron | ||
| Line 150: | Line 126: | ||
: timestamp for next due time to send notification | : timestamp for next due time to send notification | ||
; consolidatedSendIfEmpty | ; consolidatedSendIfEmpty | ||
: true|false | : true | false | ||
=== consolidated === | === consolidated === | ||
| Line 214: | Line 190: | ||
; notificationGroupId (partition key) | ; notificationGroupId (partition key) | ||
: comes from: | : comes from: hash{notifications} | ||
; time (sort key) | ; time (sort key) | ||
: comes from {timestamp activity handled in Activity Switchboard}_{small random UUID} | : comes from {timestamp activity handled in Activity Switchboard}_{small random UUID} | ||
| Line 224: | Line 200: | ||
== Object Relationships == | == Object Relationships == | ||
=== | === ownsNotificationGroup === | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
" | "ownsNotificationGroup": { | ||
fieldNames: { | fieldNames: { | ||
"originTimestamp": { | "originTimestamp": { | ||
| Line 247: | Line 223: | ||
from: { | from: { | ||
objType: { | objType: { | ||
serviceTag: " | serviceTag: "UserAccount", | ||
objectType: " | objectType: "user" | ||
}, | }, | ||
linkType: "one", | linkType: "one", | ||
| Line 266: | Line 242: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
: links | : links user to notificationGroup that user created | ||
=== | === hasNotificationGroup === | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
"hasNotificationGroup": { | "hasNotificationGroup": { | ||
fieldNames: { | |||
"originTimestamp": { | |||
type: "number", // "string" | "number" ... | |||
requiredOnCreate: true, // default = false | |||
canUpdate: true, // default = true | |||
validation: {} // ajv syntax | |||
} | |||
}, | |||
storageResources: { | |||
myGraph: { | |||
storageType: "graph", | |||
graphServerTag: "GraphHandler" | |||
} | |||
}, | |||
links: [ | |||
{ | |||
storageResourceTags: ["myGraph"], | |||
from: { | |||
objType: { | |||
serviceTag: "UserContactManager", | |||
objectType: "userContact" | |||
}, | |||
linkType: "many" | |||
}, | |||
to: { | |||
objType: { | |||
serviceTag: "NotificationManager", | |||
objectType: "notificationGroup" | |||
}, | |||
linkType: "many", | |||
handler: true | |||
} | |||
} | |||
] | |||
} | |||
} | |||
</syntaxhighlight> | |||
=== disabledNotificationGroup === | |||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"disabledNotificationGroup": { | |||
fieldNames: { | fieldNames: { | ||
"originTimestamp": { | "originTimestamp": { | ||
Revision as of 06:27, 19 March 2025
Overview
Consolidates and sends notifications to any number of receiver services. Will be used for user notifications but can have other types of receiver services added. Activities are received from Activity Switchboard service.
Notification groups set whether activities are considated (eg per day/per month/per x number of activities), if considated activities are stored here until sending is triggered, according to the considation rules. If not consolidated they are sent on immediately.
Repository
https://bitbucket.org/izara-core-shared/izara-core-shared-notification-manager
Object Schemas
- Additional Information
- Per Service Schemas
objType
notificationGroup
- Groups many triggerGroups together
{
objectType: "notificationGroup",
overWriteHandlers: { // optional, if not set will create default handlers, if empty will not create handler and main function
create: ['hdrSqs'], // default: ['hdrApi', 'hdrSqs']
update: ['hdrSqs'], // default: ['hdrApi', 'hdrSqs']
get: [], // default: ['hdrApi', 'hdrInv']
delete: [], // default: ['hdrApi', 'hdrSqs']
},
overwriteGeneratedMainFunction: ["get", "delete"],
addOnDataStructure: [
{
type: "versionedData",
versionedDataLabel: "notificationGroupSettings",
storageResourceTag: "myGraph",
fieldNames: [
{ // fieldName in versionedData should now same in main objectSchema
fieldName: "notificationGroupName",
type: "string",
optionalOnCreate: true, // default = false
canUpdate: true, // default = true
validation: {
pattern: pattern
}
},
{
fieldName: "consolidatedType",
type: "string",
optionalOnCreate: true,
canUpdate: true,
validation: {
pattern: pattern
}
},
{
fieldName: "consolidatedFrequency",
type: "string",
optionalOnCreate: true,
canUpdate: true,
validation: {
pattern: pattern
}
},
{
fieldName: "consolidatedNextSendDue",
type: "number",
optionalOnCreate: true,
canUpdate: true,
validation: {
pattern: pattern
}
},
{
fieldName: "consolidatedSendIfEmpty",
type: "boolean",
optionalOnCreate: true,
canUpdate: true,
validation: {
pattern: pattern
}
}
]
}
],
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "GraphHandler"
}
},
fieldNames: { // see Per Service Schemas
notificationGroupId: {
type: "string",
randomOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
}
},
identifiers: [
{
type: "identifier",
fieldName: "notificationGroupId"
}
]
}
fieldNames
- notificationGroupId (identifier)
- comes from: hash{notifications}
- notificationGroupName
- string name set by reciever service, optional
- consolidated (maybe remove and use consolidatedType for check consolidated )
- true | false
- consolidatedType
- overview | detailed | null
- overview sends a count of each type of notification, detailed lists each activity message
- null that mean notificationGroup is not consolidated and send to receiver service
- consolidatedFrequency
- not sure, maybe use some sort of standard like cron
- consolidatedNextSendDue
- timestamp for next due time to send notification
- consolidatedSendIfEmpty
- true | false
consolidated
{
objectType: "consolidated",
canDelete: false,
complexFilterServiceTag: "complexFilter",
overWriteHandlers: { // optional, if not set will create default handlers, if empty will not create handler and main function
create: [], // default: ['hdrApi', 'hdrSqs']
update: [], // default: ['hdrApi', 'hdrSqs']
get: [], // default: ['hdrApi', 'hdrInv']
delete: [], // default: ['hdrApi', 'hdrSqs']
},
storageResources: {
dynamoDB: {
storageType: "dynamoDB",
tableName: "PendingConsolidation"
}
},
fieldNames: {
notificationGroupId: {
type: "string",
canUpdate: false,
storageResourceTags: ['dynamoDB'],
fromServiceNameTag: "NotificationManager" ,
fromObjectType: "notificationGroup"
},
time: {
type: "string",
requiredOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['dynamoDB']
},
activityMsg: {
type: "object",
requiredOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['dynamoDB']
}
},
identifiers: [
{
type: "partitionKey",
fieldName: "notificationGroupId"
},
{
type: "sortKey",
fieldName: "time"
}
]
}
fieldNames
- notificationGroupId (partition key)
- comes from: hash{notifications}
- time (sort key)
- comes from {timestamp activity handled in Activity Switchboard}_{small random UUID}
- adding the UUID to ensure no clashing records with the same timestamp and notificationGroupId
- activityMsg
- copy of the message delivered from Activity Switchboard
Object Relationships
ownsNotificationGroup
{
"ownsNotificationGroup": {
fieldNames: {
"originTimestamp": {
type: "number", // "string" | "number" ...
requiredOnCreate: true, // default = false
canUpdate: true, // default = true
validation: {} // ajv syntax
}
},
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "graphHandler"
}
},
links: [
{
storageResourceTags: ["myGraph"],
from: {
objType: {
serviceTag: "UserAccount",
objectType: "user"
},
linkType: "one",
},
to: {
objType: {
serviceTag: "NotificationManager",
objectType: "notificationGroup"
},
requiredOnCreate: true,
linkType: "many",
handler: true
}
}
]
}
}
- links user to notificationGroup that user created
hasNotificationGroup
{
"hasNotificationGroup": {
fieldNames: {
"originTimestamp": {
type: "number", // "string" | "number" ...
requiredOnCreate: true, // default = false
canUpdate: true, // default = true
validation: {} // ajv syntax
}
},
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "GraphHandler"
}
},
links: [
{
storageResourceTags: ["myGraph"],
from: {
objType: {
serviceTag: "UserContactManager",
objectType: "userContact"
},
linkType: "many"
},
to: {
objType: {
serviceTag: "NotificationManager",
objectType: "notificationGroup"
},
linkType: "many",
handler: true
}
}
]
}
}
disabledNotificationGroup
{
"disabledNotificationGroup": {
fieldNames: {
"originTimestamp": {
type: "number", // "string" | "number" ...
requiredOnCreate: true, // default = false
canUpdate: true, // default = true
validation: {} // ajv syntax
}
},
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "GraphHandler"
}
},
links: [
{
storageResourceTags: ["myGraph"],
from: {
objType: {
serviceTag: "UserContactManager",
objectType: "userContact"
},
linkType: "many"
},
to: {
objType: {
serviceTag: "NotificationManager",
objectType: "notificationGroup"
},
linkType: "many",
handler: true
}
}
]
}
}
hasTriggerGroup
{
"hasTriggerGroup": {
fieldNames: {
"originTimestamp": {
type: "number", // "string" | "number" ...
requiredOnCreate: true, // default = false
canUpdate: true, // default = true
validation: {} // ajv syntax
}
},
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "GraphHandler"
}
},
links: [
{
storageResourceTags: ["myGraph"],
from: {
objType: {
serviceTag: "NotificationManager",
objectType: "notificationGroup"
},
linkType: "many",
handler: true
},
to: {
objType: {
serviceTag: "ActivitySwitchboard",
objectType: "triggerGroup"
},
linkType: "many"
}
}
]
}
}
disabledTriggerGroup
{
"disabledTriggerGroup": {
fieldNames: {
"originTimestamp": {
type: "number", // "string" | "number" ...
requiredOnCreate: true, // default = false
canUpdate: true, // default = true
validation: {} // ajv syntax
}
},
storageResources: {
myGraph: {
storageType: "graph",
graphServerTag: "graphHandler"
}
},
links: [
{
storageResourceTags: ["myGraph"],
from: {
objType: {
serviceTag: "NotificationManager",
objectType: "notificationGroup"
},
linkType: "many",
handler: true
},
to: {
objType: {
serviceTag: "ActivitySwitchboard",
objectType: "triggerGroup"
},
linkType: "many"
}
}
]
}
}
value or values array
- Either 'value' or 'values' should be set, not both, if 'values' is used it means any of the elements in the 'values' array can match.
- To achieve this on Activity Switchboard a new trigger group is created for each element, each activity group has the full list of other triggers, and one option from this trigger's values array. If a notification has multiple values type triggers than a new trigger group on Activity Switchboard is created for each combination.
- "serviceName" and "topicName" valueTypes do not have propertyName
serviceName and topicName triggers
- Notifications do not have to set their serviceName and/or topicName, if not set then any message that matches the properties will pass
- Can set only the serviceName, then any message that passess the properties and is from that serviceName passes
- Can set serviceName+topicName, then only messages in that topic will pass
- serviceName and topicName can both be submitted as "values" array, creating multiple trigger groups for each combination
Consolidated notifications
How to trigger processing for time based consolidations
- ....
- maybe can use some sort of queue to store a list of NotificationGroup’s that are due to be sent (either because consolidatedSendIfEmpty == true or there are some activities waiting to be processed)
Formating the notification body
- Initially the format will be hardwired and simple, but in the future we could create templates for formating the notification body
- The notificationBody is currently sent to receiver as a JSON stringified object containing all activityMsgs
Ideas
- overview notifications currently count per notification, but could be extended to do aggregates on a per notification, per field level
- If set to overview maybe can store just aggregate/s needed for the consolidated notification, at the moment store entire messages, create the overview once when sending notification