jameshartig commented on code in PR #1892:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1892#discussion_r2148901594


##########
host_source.go:
##########
@@ -492,17 +497,42 @@ func checkSystemSchema(control *controlConn) (bool, 
error) {
        return true, nil
 }
 
-func (s *Session) newHostInfoFromMap(addr net.IP, port int, row 
map[string]interface{}) (*HostInfo, error) {
-       return s.hostInfoFromMap(row, &HostInfo{connectAddress: addr, port: 
port})
-}
-
 // Given a map that represents a row from either system.local or system.peers
 // return as much information as we can in *HostInfo
-func (s *Session) hostInfoFromMap(row map[string]interface{}, host *HostInfo) 
(*HostInfo, error) {
+func (s *Session) newHostInfoFromMap(addr net.IP, port int, row 
map[string]interface{}) (*HostInfo, error) {
+       return newHostInfoFromRow(s, addr, port, row)
+}
+
+// NewTestHostInfoFromRow creates a new HostInfo object from a system.peers or 
system.local row. The port
+// defaults to 9042.
+//
+// You can create a HostInfo object for testing purposes using this function:
+//
+// Example usage:
+//
+//     row := map[string]interface{}{
+//             "broadcast_address": net.ParseIP("10.0.0.1"),
+//             "listen_address":    net.ParseIP("10.0.0.1"),
+//             "rpc_address":       net.ParseIP("10.0.0.1"),
+//             "peer":              net.ParseIP("10.0.0.1"), // system.peers 
only
+//             "data_center":       "dc1",
+//             "rack":              "rack1",
+//             "host_id":           MustRandomUUID(),        // can also use 
ParseUUID("550e8400-e29b-41d4-a716-446655440000")
+//             "release_version":   "4.0.0",
+//             "native_port":       9042,
+//     }
+//     host, err := NewTestHostInfoFromRow(row)
+func NewTestHostInfoFromRow(row map[string]interface{}) (*HostInfo, error) {

Review Comment:
   Should we have the same method on `*Session` too so it could still call 
`AddressTranslator`?



##########
host_source.go:
##########
@@ -181,9 +183,12 @@ type HostInfo struct {
        tokens           []string
 }
 
-// NewHostInfo creates HostInfo with provided connectAddress and port.
+// NewHostInfoFromContactPoint creates HostInfo with provided connectAddress 
and port.
 // It returns an error if addr is invalid.
-func NewHostInfo(addr net.IP, port int) (*HostInfo, error) {
+//
+// If you're looking for a way to create a HostInfo object with more than just 
an address and port for
+// testing purposes then you can use NewTestHostInfoFromRow
+func NewHostInfoFromContactPoint(addr net.IP, port int) (*HostInfo, error) {

Review Comment:
   nit: What's the reason behind "ContactPoint"? What about 
"NewHostInfoFromAddrPort"? Not terribly opposed with contact point though



-- 
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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to