reverseproxy: Pointer receiver

This avoids copying the Upstream, which has an atomically-accessed value
in it.
This commit is contained in:
Matthew Holt 2023-07-08 13:42:51 -06:00
parent 66114cb155
commit 5dec11f2a0
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -63,9 +63,10 @@ type Upstream struct {
unhealthy int32 // accessed atomically; status from active health checker unhealthy int32 // accessed atomically; status from active health checker
} }
func (u Upstream) String() string { // (pointer receiver necessary to avoid a race condition, since
return u.Dial // copying the Upstream reads the 'unhealthy' field which is
} // accessed atomically)
func (u *Upstream) String() string { return u.Dial }
// Available returns true if the remote host // Available returns true if the remote host
// is available to receive requests. This is // is available to receive requests. This is