Skip to content

Commit

Permalink
Skip reading more notifications if queue is full (#5240)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Jan 23, 2024
1 parent 50391ec commit 82bcec1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions backend/notification_pusher/aws/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Increase the number of notification pusher threads ([#5237](https://github.com/open-chat-labs/open-chat/pull/5237))
- Store map of invalid subscription endpoints and skip pushing to them ([#5238](https://github.com/open-chat-labs/open-chat/pull/5238))
- Skip reading more notifications if queue is full ([#5240](https://github.com/open-chat-labs/open-chat/pull/5240))

## [[2.0.970](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.970-notifications_pusher)] - 2023-12-12

Expand Down
21 changes: 13 additions & 8 deletions backend/notification_pusher/core/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,21 @@ impl<I: IndexStore> Reader<I> {

let mut interval = time::interval(time::Duration::from_secs(2));
loop {
for _ in 0..30 {
if let Err(error) = self.read_notifications().await {
error!(?error, "Read notifications failed");
}

if self.sender.is_full() {
error!("Notifications queue is full");
interval.tick().await;
}
} else {
for _ in 0..30 {
if let Err(error) = self.read_notifications().await {
error!(?error, "Read notifications failed");
}

if let Err(error) = self.prune_notifications().await {
error!(?error, "Prune notifications failed");
interval.tick().await;
}

if let Err(error) = self.prune_notifications().await {
error!(?error, "Prune notifications failed");
}
}
}
}
Expand Down

0 comments on commit 82bcec1

Please sign in to comment.