Skip to content

Debounce notifications #49

@link2xt

Description

@link2xt

When notification arrives, we should debounce them.

For that, store notification tokens in a binary tree or binary heap sorted by timestamp of their last notification. At the same time maintain a set of all tokens which are currently in the heap (the values).

When a new notification arrives, first clean up the heap by removing tokens that have been notified >10 seconds ago and corresponding set entries. Then check the set, if it still has the token, do not notify.

If the set does not have the token, the notification is not debounced. Notify and on success insert the token both into the binary tree and in the set.

We also need metrics:

  1. Gauge for the number of tokens currently in the set.
  2. Counter for the number of debounced notifications.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions