Skip to content
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

Implement missing pieces for connection backoff. #2821

Closed
wants to merge 20 commits into from

Conversation

easwars
Copy link
Contributor

@easwars easwars commented May 16, 2019

These are the same set of changes initially proposed in #2735.

#2724

@easwars easwars requested a review from dfawley May 16, 2019 22:11
@dfawley dfawley self-assigned this May 23, 2019
@euroelessar
Copy link

@dfawley @easwars Hi, any progress on this change?

// interface used to build an exponential backoff strategy implementation, as
// defined in
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md.
func NewExponentialBuilder() StrategyBuilder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go doesn't typically have builders or getters/setters. Just structs with fields.

Why not simply export the fields in Exponential?

Defaults could be handled by something like:

package backoff

var DefaultExponential = Exponential{<defaults>}
...
package grpc

s := DefaultExponential
s.BaseDelay = 10*time.Second

or

Make all the fields pointers and handle nil pointers in the Backoff function. This is a bit more painful to use and handle, though you could make it easy to use with helpers like func DurationPtr(d time.Duration) *time.Duration { return &d }.

@@ -69,6 +74,7 @@ type dialOptions struct {
minConnectTimeout func() time.Duration
defaultServiceConfig *ServiceConfig // defaultServiceConfig is parsed from defaultServiceConfigRawJSON.
defaultServiceConfigRawJSON *string
mct time.Duration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a minConnectTimeout func() time.Duration above - this would be duplicating that.

Also, in general: try not to use short names for things outside a small scope (i.e. a short function or a struct with 1-2 fields where it's entirely obvious what the short name means (e.g. timer.C)).

//
// This API is EXPERIMENTAL.
type ConnectParams struct {
// BackoffBaseDelay is the amount of time to backoff after the first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace all the backoff fields here with a single BackoffConfig field, and add these fields to the BackoffConfig (excluding MinConnectTimeout)? Theoretically we could pass BackoffConfig to Exponential directly, though that is unfortunately not easy because it's in a different package and has circular dependency issues. We'd need a new, non-internal backoff package. This may actually be a good idea.

@dfawley dfawley assigned easwars and unassigned dfawley Jul 31, 2019
Move MinConnectionTimeout() out of backoff.Strategy interface. Store
it directly in dialOptions instead, and have ClientConn use it from
there.
I need to roll these back because I had sent out changes from my master
branch, and this is causing a lot of pain right now for my work on other
branches. I will create a branch for this issue and will send out these
changes in a fresh PR.
@easwars
Copy link
Contributor Author

easwars commented Aug 6, 2019

Tracked in #2960.

@easwars easwars closed this Aug 6, 2019
@easwars easwars deleted the backoff branch November 20, 2019 17:10
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants