Skip to content

Commit e7bab5c

Browse files
committed
Remove unnecessary mut references
1 parent 359c9a4 commit e7bab5c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

databroker/src/broker.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl Subscriptions {
607607
}
608608

609609
pub async fn notify(
610-
&mut self,
610+
&self,
611611
changed: Option<&HashMap<i32, HashSet<Field>>>,
612612
db: &Database,
613613
) -> Result<Option<HashMap<String, ()>>, NotificationError> {
@@ -627,7 +627,7 @@ impl Subscriptions {
627627
}
628628
}
629629

630-
for sub in &mut self.change_subscriptions {
630+
for sub in &self.change_subscriptions {
631631
match sub.notify(changed, db).await {
632632
Ok(_) => {}
633633
Err(err) => error = Some(err),
@@ -660,7 +660,7 @@ impl Subscriptions {
660660
true
661661
}
662662
});
663-
self.change_subscriptions.retain_mut(|sub| {
663+
self.change_subscriptions.retain(|sub| {
664664
if sub.sender.is_closed() {
665665
info!("Subscriber gone: removing subscription");
666666
false
@@ -671,7 +671,10 @@ impl Subscriptions {
671671
info!("Token expired: removing subscription");
672672
false
673673
}
674-
Err(err) => panic!("Error: {:?}", err),
674+
Err(err) => {
675+
info!("Error: {:?} -> removing subscription", err);
676+
false
677+
}
675678
}
676679
}
677680
});
@@ -745,7 +748,7 @@ impl ChangeSubscription {
745748
if notifications.updates.is_empty() {
746749
Ok(())
747750
} else {
748-
match &self.sender.send(notifications).await {
751+
match self.sender.send(notifications).await {
749752
Ok(()) => Ok(()),
750753
Err(_) => Err(NotificationError {}),
751754
}
@@ -785,7 +788,7 @@ impl ChangeSubscription {
785788
}
786789
notifications
787790
};
788-
match &self.sender.send(notifications).await {
791+
match self.sender.send(notifications).await {
789792
Ok(()) => Ok(()),
790793
Err(_) => Err(NotificationError {}),
791794
}
@@ -1421,7 +1424,7 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> {
14211424
match self
14221425
.broker
14231426
.subscriptions
1424-
.write()
1427+
.read()
14251428
.await
14261429
.notify(Some(&changed), &db)
14271430
.await

0 commit comments

Comments
 (0)