Skip to content

Commit

Permalink
Transport/Connection: consider attributes values for equality
Browse files Browse the repository at this point in the history
Two hosts must be considered as different if their attributes differ.
If we don't, on hosts list refreshing, if hosts have the same IP and
port, but have updated attributes, we will always consider hosts are the
same and won't take the new attributes into account.

On startup, hosts do not have any attributes.
On the first call of client.transport.reload_connections!, we fetch the
nodes list with their attributes, remove hosts that have been
disappeared and add new hosts.
However, we use this equality to detect if the hosts were already in the
current list of nodes or node.
If the client was configured with a nodes list that have the same name
as the published hostname and port, the nodes with attributes will be
considered equals as nodes without and we will never save the attributes
in the list. And the Selector can't use attributes.
  • Loading branch information
chtitux authored and picandocodigo committed Jun 24, 2020
1 parent 8437f50 commit 06ffd03
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,15 @@ def resurrectable?
}
end

# Equality operator based on connection protocol, host and port
# Equality operator based on connection protocol, host, port and attributes
#
# @return [Boolean]
#
def ==(other)
self.host[:protocol] == other.host[:protocol] && \
self.host[:host] == other.host[:host] && \
self.host[:port].to_i == other.host[:port].to_i
self.host[:port].to_i == other.host[:port].to_i && \
self.host[:attributes] == other.host[:attributes]
end

# @return [String]
Expand Down

0 comments on commit 06ffd03

Please sign in to comment.