Cleaning up event subscriptions after the max age window

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-11-02 14:13:48 +01:00
parent 5077e1262d
commit b7d0334f14
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-events-backend': patch
---
Cleaning up event subscriptions after the max age window
@@ -602,7 +602,9 @@ export class DatabaseEventBusStore implements EventBusStore {
if (minId === null) {
// No events left, remove all subscribers. This can happen if no events
// are published within the max age window.
subscriberCount = await this.#db(TABLE_SUBSCRIPTIONS).delete();
subscriberCount = await this.#db(TABLE_SUBSCRIPTIONS)
.where('updated_at', '<', new Date(Date.now() - this.#windowMaxAge))
.delete();
} else {
subscriberCount = await this.#db(TABLE_SUBSCRIPTIONS)
.delete()