Skip to content

Commit

Permalink
update remove_endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed Sep 20, 2023
1 parent 5529414 commit 1f4d587
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
10 changes: 2 additions & 8 deletions src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,8 @@ impl ClusterMap {
self.insert(None, endpoints);
}

pub fn remove_endpoint(&self, endpoint: &Endpoint) -> bool {
for mut entry in self.0.iter_mut() {
if entry.value_mut().remove(endpoint) {
return true;
}
}

false
pub fn remove_endpoint(&self, needle: &Endpoint) -> bool {
self.remove_endpoint_if(|endpoint| endpoint.address == needle.address)
}

pub fn remove_endpoint_if(&self, closure: impl Fn(&Endpoint) -> bool) -> bool {
Expand Down
11 changes: 1 addition & 10 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ pub use self::{address::EndpointAddress, locality::Locality};
pub type EndpointMetadata = crate::metadata::MetadataView<Metadata>;

/// A destination endpoint with any associated metadata.
/// For the purposes of comparison between endpoints, metadata is ignored.
#[derive(Debug, Deserialize, Serialize, Clone, schemars::JsonSchema)]
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone, Eq, schemars::JsonSchema)]
#[non_exhaustive]
#[serde(deny_unknown_fields)]
pub struct Endpoint {
Expand All @@ -37,14 +36,6 @@ pub struct Endpoint {
pub metadata: EndpointMetadata,
}

impl PartialEq for Endpoint {
fn eq(&self, rhs: &Self) -> bool {
self.address == rhs.address
}
}

impl Eq for Endpoint {}

impl Endpoint {
/// Creates a new [`Endpoint`] with no metadata.
pub fn new(address: EndpointAddress) -> Self {
Expand Down

0 comments on commit 1f4d587

Please sign in to comment.