Cleaning up event subscriptions after the max age window
Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user