Skip to content

refactor:rename clientside dialoption field 'maxAttempts' #7391

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error)
}

if cc.dopts.defaultServiceConfigRawJSON != nil {
scpr := parseServiceConfig(*cc.dopts.defaultServiceConfigRawJSON, cc.dopts.maxCallAttempts)
scpr := parseServiceConfig(*cc.dopts.defaultServiceConfigRawJSON, cc.dopts.maxRetryAttempts)
if scpr.Err != nil {
return nil, fmt.Errorf("%s: %v", invalidDefaultServiceConfigErrPrefix, scpr.Err)
}
Expand Down Expand Up @@ -696,7 +696,7 @@ func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) error {
var emptyServiceConfig *ServiceConfig

func init() {
cfg := parseServiceConfig("{}", defaultMaxCallAttempts)
cfg := parseServiceConfig("{}", defaultMaxRetryAttempts)
if cfg.Err != nil {
panic(fmt.Sprintf("impossible error parsing empty service config: %v", cfg.Err))
}
Expand Down
20 changes: 10 additions & 10 deletions dialoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (

const (
// https://github.com/grpc/proposal/blob/master/A6-client-retries.md#limits-on-retries-and-hedges
defaultMaxCallAttempts = 5
defaultMaxRetryAttempts = 5
)

func init() {
Expand Down Expand Up @@ -94,7 +94,7 @@ type dialOptions struct {
idleTimeout time.Duration
recvBufferPool SharedBufferPool
defaultScheme string
maxCallAttempts int
maxRetryAttempts int
}

// DialOption configures how we set up the connection.
Expand Down Expand Up @@ -678,12 +678,12 @@ func defaultDialOptions() dialOptions {
UseProxy: true,
UserAgent: grpcUA,
},
bs: internalbackoff.DefaultExponential,
healthCheckFunc: internal.HealthCheckFunc,
idleTimeout: 30 * time.Minute,
recvBufferPool: nopBufferPool{},
defaultScheme: "dns",
maxCallAttempts: defaultMaxCallAttempts,
bs: internalbackoff.DefaultExponential,
healthCheckFunc: internal.HealthCheckFunc,
idleTimeout: 30 * time.Minute,
recvBufferPool: nopBufferPool{},
defaultScheme: "dns",
maxRetryAttempts: defaultMaxRetryAttempts,
}
}

Expand Down Expand Up @@ -752,9 +752,9 @@ func WithIdleTimeout(d time.Duration) DialOption {
func WithMaxCallAttempts(n int) DialOption {
return newFuncDialOption(func(o *dialOptions) {
if n < 2 {
n = defaultMaxCallAttempts
n = defaultMaxRetryAttempts
}
o.maxCallAttempts = n
o.maxRetryAttempts = n
})
}

Expand Down
2 changes: 1 addition & 1 deletion resolver_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (ccr *ccResolverWrapper) NewAddress(addrs []resolver.Address) {
// ParseServiceConfig is called by resolver implementations to parse a JSON
// representation of the service config.
func (ccr *ccResolverWrapper) ParseServiceConfig(scJSON string) *serviceconfig.ParseResult {
return parseServiceConfig(scJSON, ccr.cc.dopts.maxCallAttempts)
return parseServiceConfig(scJSON, ccr.cc.dopts.maxRetryAttempts)
}

// addChannelzTraceEvent adds a channelz trace event containing the new
Expand Down
2 changes: 1 addition & 1 deletion service_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ type jsonSC struct {

func init() {
internal.ParseServiceConfig = func(js string) *serviceconfig.ParseResult {
return parseServiceConfig(js, defaultMaxCallAttempts)
return parseServiceConfig(js, defaultMaxRetryAttempts)
}
}
func parseServiceConfig(js string, maxAttempts int) *serviceconfig.ParseResult {
Expand Down
2 changes: 1 addition & 1 deletion service_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func runParseTests(t *testing.T, testCases []parseTestCase) {
t.Helper()
for i, c := range testCases {
t.Run(fmt.Sprint(i), func(t *testing.T) {
scpr := parseServiceConfig(c.scjs, defaultMaxCallAttempts)
scpr := parseServiceConfig(c.scjs, defaultMaxRetryAttempts)
var sc *ServiceConfig
sc, _ = scpr.Config.(*ServiceConfig)
if !c.wantErr {
Expand Down