Skip to content

Commit

Permalink
Remove optional
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmittag committed Apr 17, 2024
1 parent 64f0cf6 commit b6733c9
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions databroker/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub struct QuerySubscription {

pub struct ChangeSubscription {
entries: HashMap<i32, HashSet<Field>>,
sender: Option<mpsc::Sender<EntryUpdates>>,
sender: mpsc::Sender<EntryUpdates>,
permissions: Permissions,
}

Expand Down Expand Up @@ -661,8 +661,7 @@ impl Subscriptions {
}
});
self.change_subscriptions.retain_mut(|sub| {
if let Some(sender) = &sub.sender {
if sender.is_closed() {
if sub.sender.is_closed() {
info!("Subscriber gone: removing subscription");
false
} else {
Expand All @@ -675,10 +674,6 @@ impl Subscriptions {
Err(err) => panic!("Error: {:?}", err),
}
}
} else {
info!("Subscriber gone: removing subscription");
false
}
});
}
}
Expand Down Expand Up @@ -749,13 +744,12 @@ impl ChangeSubscription {
};
if notifications.updates.is_empty() {
Ok(())
} else if let Some(sender) = &self.sender {
match sender.send(notifications).await {
}
else {
match &self.sender.send(notifications).await {
Ok(()) => Ok(()),
Err(_) => Err(NotificationError {}),
}
} else {
Err(NotificationError {})
}
} else {
Ok(())
Expand Down Expand Up @@ -792,13 +786,10 @@ impl ChangeSubscription {
}
notifications
};
if let Some(sender) = &self.sender {
match sender.send(notifications).await {
Ok(()) => Ok(()),
Err(_) => Err(NotificationError {}),
}
} else {
Err(NotificationError {})
match &self.sender.send(notifications).await
{
Ok(()) => Ok(()),
Err(_) => Err(NotificationError {}),
}
}
}
Expand Down Expand Up @@ -1478,7 +1469,7 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> {
let (sender, receiver) = mpsc::channel(10);
let subscription = ChangeSubscription {
entries: valid_entries,
sender: Some(sender),
sender: sender,
permissions: self.permissions.clone(),
};

Expand Down

0 comments on commit b6733c9

Please sign in to comment.