joao-r-reis commented on code in PR #1912:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1912#discussion_r2378964049


##########
session.go:
##########
@@ -944,14 +949,26 @@ func (qm *queryMetrics) attempt(addAttempts int, 
addLatency time.Duration,
        updateHostMetrics.Attempts += addAttempts
        updateHostMetrics.TotalLatency += addLatency.Nanoseconds()
 
-       var hostMetricsCopy *hostMetrics
-       if needsHostMetrics {
-               hostMetricsCopy = new(hostMetrics)
-               *hostMetricsCopy = *updateHostMetrics
-       }
-
        qm.l.Unlock()
-       return totalAttempts, hostMetricsCopy
+       return totalAttempts, updateHostMetrics
+}
+
+var nilHostMetrics = &hostMetrics{}

Review Comment:
   Yeah my first implementation of this was a truly nil object but I realized 
later that `attempts` is used for retry policies so can't get rid of that one. 
Also I called it `nil` because of the [Null Object 
Pattern](https://en.wikipedia.org/wiki/Null_object_pattern) but I'm not even 
sure if using this name in the context of Go is a good idea so I'll just rename 
it to `empty` anyway.



-- 
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