Skip to content

Backgrounding of NotificationsManagerfor Fault Tolerance #703

@amydevs

Description

@amydevs

Specification

Currently the sending of notifications is entirely synchronous. The NotificationsManager.sendNotifcationcurrently blocks until the Notification has either been sent or failed to be sent.

Untitled-2023-10-23-0424 excalidraw

In order to make the NotificationManager more fault tolerant, the sending of notifications needs to be assigned to a TaskManager task instead. This task needs to reschedule itself with a delay that doubles each retry. This would require a refactor of the notifications domain to abstract over the TaskManager in queuing notifications, but it would give us an outbox/inbox system similar to emails.

Expanded RPC Handlers

Untitled-2023-10-23-0424 excalidraw

The RPC handlers need to be expanded to add ability to both clear the notifications of the outbox and remove a pending notification from the outbox.

NotificationIds

NotifcationIds need to be exposed on the notifications themselves, much like how AuditEventIds are exposed on the AuditEvents. The reason for this is because the user should be able to delete Notifications / cancel a pending Notification in the outbox. This was already discussed as an improvement during MatrixAI/Polykey-CLI#50, but there is an actual need for it now. The Encoded version of the NotificationId will be available both in the Notifications returned by read*Notificaitons, but not in the database itself. The reason for this is because the database already stores the ID as the key, which is then filled in as a field in the Notificaiton returned by read*Notifications methods.

Additional context

Tasks

  1. Implement non-blocking NotificaitonsManager.sendNotification
  2. Implement exposing NotificationIds on Notifications
  3. Implement readOutboxNotifications, removeOutboxNotification, and clearOutboxNotifications
  4. Rename readNotifications, removeNotification, and clearNotifications to readInboxxNotifications, removeInboxNotification, and clearInboxNotifications respectively

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions