backoff: make DefaultBackoffConfig a concrete value

To enforce immutability of the `DefaultBackoffConfig`, we've made it a
concrete value. While fields can still be set directly on the value,
taking a copy will not incidentally pull a reference to the variable.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2016-04-18 11:33:39 -07:00
parent 9ff38e9093
commit 8ef1dcabab
4 changed files with 16 additions and 13 deletions

View File

@ -118,7 +118,7 @@ func WithPicker(p Picker) DialOption {
// WithBackoffMaxDelay configures the dialer to use the provided maximum delay
// when backing off after failed connection attempts.
func WithBackoffMaxDelay(md time.Duration) DialOption {
return WithBackoffConfig(&BackoffConfig{MaxDelay: md})
return WithBackoffConfig(BackoffConfig{MaxDelay: md})
}
// WithBackoffConfig configures the dialer to use the provided backoff
@ -126,7 +126,7 @@ func WithBackoffMaxDelay(md time.Duration) DialOption {
//
// Use WithBackoffMaxDelay until more parameters on BackoffConfig are opened up
// for use.
func WithBackoffConfig(b *BackoffConfig) DialOption {
func WithBackoffConfig(b BackoffConfig) DialOption {
// Set defaults to ensure that provided BackoffConfig is valid and
// unexported fields get default values.
b.setDefaults()