-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client: add WithConnectParams to configure connection backoff and timeout #2960
Conversation
@dfawley
|
Fixed the merge conflicts. |
|
I have moved the backoff configuration parameters to a new package. PTAL. |
Ping @dfawley |
Spec can be found here: https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md Summary of changes: * Added a new type (marked experimental), ConnectParams, which contains the knobs defined in the spec (except for minConnectTimeout). * Added a new API (marked experimental), WithConnectParams() to return a DialOption to dial with the provided parameters. * Added new fields to the implementation of the exponential backoff in internal/backoff which mirror the ones in ConnectParams. * Marked existing APIs WithBackoffMaxDelay() and WithBackoffConfig() as deprecated. * Added a default exponential backoff implementation, for easy use of internal callers.
Added a new backoff package which defines the backoff configuration options, and is used by both the grpc package and the internal/backoff package. This allows us to have all backoff related options in a separate package.
e90fd41
to
dea6444
Compare
backoff.go
Outdated
@@ -27,12 +27,34 @@ import ( | |||
|
|||
// DefaultBackoffConfig uses values specified for backoff in | |||
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. | |||
// | |||
// Deprecated: use ConnectParams instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clarify that this will be supported throughout 1.x (copy/paste similar deprecation comments elsewhere in grpc package).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
backoff.go
Outdated
var DefaultBackoffConfig = BackoffConfig{ | ||
MaxDelay: 120 * time.Second, | ||
} | ||
|
||
// BackoffConfig defines the parameters for the default gRPC backoff strategy. | ||
// | ||
// Deprecated: use ConnectParams instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
backoff.go
Outdated
@@ -23,16 +23,36 @@ package grpc | |||
|
|||
import ( | |||
"time" | |||
|
|||
grpcbackoff "google.golang.org/grpc/backoff" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to rename in this file. I'm worried a renaming here might affect godoc for the ConnectParams field (? not sure about it though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Removed unnecessary import renaming.
Hmm .... does import renaming affect godoc? I couldn't find any documentation to that effect.
backoff/backoff.go
Outdated
// details can be found at | ||
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. | ||
// | ||
// This API is EXPERIMENTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this comment to the whole package level instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually referring to the "EXPERIMENTAL" part. Please mark the whole file as experimental. Following the same wording as resolver/resolver.go
:
// All APIs in this package are experimental.
backoff/backoff.go
Outdated
* | ||
*/ | ||
|
||
// Package backoff provides configuration options for connection backoff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/connection//? This can be (and is/will be) used for other things as well as connection backoffs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
clientconn_test.go
Outdated
@@ -30,6 +30,7 @@ import ( | |||
"time" | |||
|
|||
"golang.org/x/net/http2" | |||
grpcbackoff "google.golang.org/grpc/backoff" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to nit-pick, but I would prefer to rename internal/backoff
and leave "main" packages like this not renamed where possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -246,21 +247,34 @@ func WithServiceConfig(c <-chan ServiceConfig) DialOption { | |||
}) | |||
} | |||
|
|||
// WithConnectParams configures the dialer to use the provided ConnectParams. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the best place to document our defaults?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the comments a bit more verbose.
dialoptions.go
Outdated
// WithBackoffMaxDelay configures the dialer to use the provided maximum delay | ||
// when backing off after failed connection attempts. | ||
// | ||
//Deprecated: use WithConnectParams instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange character (between //
and Deprecated
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any strange character here :)
dialoptions.go
Outdated
func WithBackoffMaxDelay(md time.Duration) DialOption { | ||
return WithBackoffConfig(BackoffConfig{MaxDelay: md}) | ||
} | ||
|
||
// WithBackoffConfig configures the dialer to use the provided backoff | ||
// parameters after connection failures. | ||
// | ||
// Use WithBackoffMaxDelay until more parameters on BackoffConfig are opened up | ||
// for use. | ||
//Deprecated: use WithConnectParams instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL. Removed unnecessary import renaming wherever possible, and where required renamed the internal/backoff package instead of grpc/backoff package.
backoff.go
Outdated
@@ -27,12 +27,34 @@ import ( | |||
|
|||
// DefaultBackoffConfig uses values specified for backoff in | |||
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. | |||
// | |||
// Deprecated: use ConnectParams instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
backoff.go
Outdated
var DefaultBackoffConfig = BackoffConfig{ | ||
MaxDelay: 120 * time.Second, | ||
} | ||
|
||
// BackoffConfig defines the parameters for the default gRPC backoff strategy. | ||
// | ||
// Deprecated: use ConnectParams instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
backoff.go
Outdated
@@ -23,16 +23,36 @@ package grpc | |||
|
|||
import ( | |||
"time" | |||
|
|||
grpcbackoff "google.golang.org/grpc/backoff" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Removed unnecessary import renaming.
Hmm .... does import renaming affect godoc? I couldn't find any documentation to that effect.
backoff/backoff.go
Outdated
* | ||
*/ | ||
|
||
// Package backoff provides configuration options for connection backoff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
backoff/backoff.go
Outdated
// details can be found at | ||
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. | ||
// | ||
// This API is EXPERIMENTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
clientconn_test.go
Outdated
@@ -30,6 +30,7 @@ import ( | |||
"time" | |||
|
|||
"golang.org/x/net/http2" | |||
grpcbackoff "google.golang.org/grpc/backoff" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
dialoptions.go
Outdated
func WithBackoffMaxDelay(md time.Duration) DialOption { | ||
return WithBackoffConfig(BackoffConfig{MaxDelay: md}) | ||
} | ||
|
||
// WithBackoffConfig configures the dialer to use the provided backoff | ||
// parameters after connection failures. | ||
// | ||
// Use WithBackoffMaxDelay until more parameters on BackoffConfig are opened up | ||
// for use. | ||
//Deprecated: use WithConnectParams instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
dialoptions.go
Outdated
// WithBackoffMaxDelay configures the dialer to use the provided maximum delay | ||
// when backing off after failed connection attempts. | ||
// | ||
//Deprecated: use WithConnectParams instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any strange character here :)
@@ -246,21 +247,34 @@ func WithServiceConfig(c <-chan ServiceConfig) DialOption { | |||
}) | |||
} | |||
|
|||
// WithConnectParams configures the dialer to use the provided ConnectParams. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the comments a bit more verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does import renaming affect godoc
I am not sure. I would hope not, but I also wouldn't be too surprised if it did.
backoff/backoff.go
Outdated
// details can be found at | ||
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. | ||
// | ||
// This API is EXPERIMENTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually referring to the "EXPERIMENTAL" part. Please mark the whole file as experimental. Following the same wording as resolver/resolver.go
:
// All APIs in this package are experimental.
Fixes #2724