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_message
  • Loading branch information
dippi committed Jul 4, 2021
commit f17107170770f58b5416d7d1088b8ed0711dcd65
24 changes: 9 additions & 15 deletions src/client/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,22 +264,16 @@ fn process_message(
topic: &str,
msg: resp::RespValue,
) -> Result<bool, error::Error> {
match subscriptions.get(topic) {
Some(sender) => {
if let Err(error) = sender.unbounded_send(Ok(msg)) {
if !error.is_disconnected() {
return Err(error::internal(format!("Cannot send message: {}", error)));
}
}
}
None => {
return Err(error::internal(format!(
"Unexpected message on topic: {}",
topic
)));
let sender = subscriptions.get(topic).ok_or(error::internal(format!(
"Unexpected message on topic: {}",
topic
)))?;
match sender.unbounded_send(Ok(msg)) {
Err(error) if !error.is_disconnected() => {
Err(error::internal(format!("Cannot send message: {}", error)))
}
};
Ok(true)
_ => Ok(true),
}
}

impl Future for PubsubConnectionInner {
Expand Down