Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor process_subscribe
  • Loading branch information
dippi committed Jul 4, 2021
commit 6b4b4341903f4257784a729ca0165eae4f8daaec
22 changes: 8 additions & 14 deletions src/client/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,14 @@ fn process_subscribe(
subscriptions: &mut BTreeMap<String, PubsubSink>,
topic: String,
) -> Result<bool, error::Error> {
match pending_subs.remove(&topic) {
Some((sender, signal)) => {
subscriptions.insert(topic, sender);
signal
.send(())
.map_err(|()| error::internal("Error confirming subscription"))?
}
None => {
return Err(error::internal(format!(
"Received unexpected subscribe notification for topic: {}",
topic
)));
}
};
let (sender, signal) = pending_subs.remove(&topic).ok_or(error::internal(format!(
"Received unexpected subscribe notification for topic: {}",
topic
)))?;
subscriptions.insert(topic, sender);
signal
.send(())
.map_err(|()| error::internal("Error confirming subscription"))?;
Ok(true)
}

Expand Down