Skip to content

Commit

Permalink
cleanup unused connections when load balancing mode is active (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielePalaia authored Oct 31, 2024
1 parent ac1f614 commit 4f78182
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ impl ConsumerBuilder {
let mapping = temp_client.connection_properties().await;
if let Some(advertised_host) = mapping.get("advertised_host") {
if *advertised_host == replica.host.clone() {
client.close().await?;
client = temp_client;
break;
}
}
temp_client.close().await?;
}
} else {
client.close().await?;
Expand Down
2 changes: 2 additions & 0 deletions src/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,12 @@ impl<T> ProducerBuilder<T> {
let mapping = temp_client.connection_properties().await;
if let Some(advertised_host) = mapping.get("advertised_host") {
if *advertised_host == metadata.leader.host.clone() {
client.close().await?;
client = temp_client;
break;
}
}
temp_client.close().await?;
}
} else {
client.close().await?;
Expand Down

0 comments on commit 4f78182

Please sign in to comment.