joao-r-reis commented on PR #1858:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1858#issuecomment-2607687794

   I just had a realization that we are probably going about this the wrong 
way. Instead of changing `ConnectAddress()` to return an `error` we should 
probably ensure that we never create `Host` objects with invalid addresses in 
the first place, I think that would result in a clearer API and less intrusive 
changes to users.
   
   Sorry for not realizing this earlier, I know you already worked a bit on 
this approach but I really think we should change the approach here. 
   
   First step is to find all occurences of straight `Host` struct 
initialization and replace them with a `newHostInfo(addr net.IP, port int) 
(*Host, error)` so that the ip validation occurs here in this method instead of 
`host.ConnectAddress()`. The only place where it will require some more changes 
is in `func (r *ringDescriber) getClusterPeerInfo(localHost *HostInfo) 
([]*HostInfo, error)` because here the object is created without an IP address 
since it will be set after reading the columns from `system.peers`. A possible 
approach is to move the logic from `h.connectAddressLocked()` to a function 
outside of the `hostinfo` type, use it to compute the connect address and then 
use the result to create the host info object afterwards. After this change, I 
think `h.ConnectAddress()` can always read the value from the 
`h.connectAddress` field.  After this change, `h.SetConnectAddress` should be 
changed to return an error in case the provided address is invalid (this is 
only in case a use
 r is using this function because the driver itself doesn't use it).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to