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
Add comment referencing the issue #50
  • Loading branch information
dippi committed Jul 4, 2021
commit 23a85ec51830f1c286c7edc7ef6cfd950fb087bd
45 changes: 21 additions & 24 deletions src/client/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,32 +193,28 @@ impl PubsubConnectionInner {
)));
}
},
b"unsubscribe" => {
match self.subscriptions.entry(topic) {
Entry::Occupied(entry) => {
entry.remove_entry();
}
Entry::Vacant(vacant) => {
return Err(error::internal(format!(
"Unexpected unsubscribe message: {}",
vacant.key()
)));
}
b"unsubscribe" => match self.subscriptions.entry(topic) {
Entry::Occupied(entry) => {
entry.remove_entry();
}
}
b"punsubscribe" => {
match self.psubscriptions.entry(topic) {
Entry::Occupied(entry) => {
entry.remove_entry();
}
Entry::Vacant(vacant) => {
return Err(error::internal(format!(
"Unexpected unsubscribe message: {}",
vacant.key()
)));
}
Entry::Vacant(vacant) => {
return Err(error::internal(format!(
"Unexpected unsubscribe message: {}",
vacant.key()
)));
}
}
},
b"punsubscribe" => match self.psubscriptions.entry(topic) {
Entry::Occupied(entry) => {
entry.remove_entry();
}
Entry::Vacant(vacant) => {
return Err(error::internal(format!(
"Unexpected unsubscribe message: {}",
vacant.key()
)));
}
},
b"message" => match self.subscriptions.get(&topic) {
Some(sender) => {
if let Err(error) = sender.unbounded_send(Ok(msg)) {
Expand Down Expand Up @@ -531,6 +527,7 @@ mod test {
}

#[tokio::test]
/// Regression test for https://github.com/benashford/redis-async-rs/issues/50
async fn test_connection_remains_open_after_unsubscription() {
let addr = "127.0.0.1:6379".parse().unwrap();
let pubsub = super::pubsub_connect(addr)
Expand Down