Service - Notification Manager

From Izara Wiki
Revision as of 02:35, 10 November 2020 by Sven the Barbarian (talk | contribs)
Jump to navigation Jump to search

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/stb_working/notification-manager/src/master/

DynamoDB tables

Standard Config Table Per Service

Configuration tags

configKey = receiver, configTag = {receiverTag}
configValue example
{
	// .. other receiver level configuration options, eg max length of notification body
	"endpoint": {
		"endpoint": {eg: Lambda function name}
		"service_type": {eg: "Lambda"} //service type tag, at the moment only "Lambda"
	}
}

NotificationGroups

  • Groups many notificatons together
  • Simplifies management of similar notifications
  • Allows for consolidation of notifications at notification group level

Fields

notificationGroupId
(partition key)
comes from: {receiverTag}_{grouping id given be receiver service}
eg receiverTag: userContactMgr
eg grouping id: userId or userId+methodTag hash
receiverSortKey
(sort key)
optional (? might have to set something) key that specifies a unique notification group within the receiver's grouping id
eg: a uuid created by UserContactManager
notificationGroupName
string name set by reciever service, optional
consolidated
true|false
consolidatedType
overview|detailed
overview sends a count of each type of notification, detailed lists each activity message
consolidatedFrequency
not sure, maybe use some sort of standard like cron
consolidatedNextSendDue
timestamp for next due time to send notification
consolidatedSendIfEmpty
true|false

Notifications

  • no sort key

Fields

notificationId
(partition key)
random UUID
notificationGroupId
serviceName
msgTag
notificationName
string name set by reciever service, optional
triggers
array/list of triggers that must match for this notification to happen, see #Triggers structure

PendingConsolidation

Fields

notificationGroupId
(partition key)
time
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

Triggers structure

Record of the triggers for a notification, saved in Notifications table

[
	{
		"property": {can be a nested property, use dot notation}
		"value": {string or number}
		"values": {array/list of values}
		"meta": true|false // default false, if true will search message attributes or other special cases like msgTag
	},
	..
]
  • either value or values is set, not both

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

Working documents

Working documents - Notification Manager