Skip to content

Commit 72b2cf2

Browse files
Merge pull request #1 from No-SilverBullet/fix/grpc_retry
Fix/grpc retry
2 parents bdd707e + 96adebd commit 72b2cf2

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

clientconn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error)
173173
}
174174

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

698698
func init() {
699-
cfg := parseServiceConfig("{}", defaultMaxCallAttempts)
699+
cfg := parseServiceConfig("{}", defaultMaxRetryAttempts)
700700
if cfg.Err != nil {
701701
panic(fmt.Sprintf("impossible error parsing empty service config: %v", cfg.Err))
702702
}

dialoptions.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939

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

4545
func init() {
@@ -94,7 +94,7 @@ type dialOptions struct {
9494
idleTimeout time.Duration
9595
recvBufferPool SharedBufferPool
9696
defaultScheme string
97-
maxCallAttempts int
97+
maxRetryAttempts int
9898
}
9999

100100
// DialOption configures how we set up the connection.
@@ -678,12 +678,12 @@ func defaultDialOptions() dialOptions {
678678
UseProxy: true,
679679
UserAgent: grpcUA,
680680
},
681-
bs: internalbackoff.DefaultExponential,
682-
healthCheckFunc: internal.HealthCheckFunc,
683-
idleTimeout: 30 * time.Minute,
684-
recvBufferPool: nopBufferPool{},
685-
defaultScheme: "dns",
686-
maxCallAttempts: defaultMaxCallAttempts,
681+
bs: internalbackoff.DefaultExponential,
682+
healthCheckFunc: internal.HealthCheckFunc,
683+
idleTimeout: 30 * time.Minute,
684+
recvBufferPool: nopBufferPool{},
685+
defaultScheme: "dns",
686+
maxRetryAttempts: defaultMaxRetryAttempts,
687687
}
688688
}
689689

@@ -752,9 +752,9 @@ func WithIdleTimeout(d time.Duration) DialOption {
752752
func WithMaxCallAttempts(n int) DialOption {
753753
return newFuncDialOption(func(o *dialOptions) {
754754
if n < 2 {
755-
n = defaultMaxCallAttempts
755+
n = defaultMaxRetryAttempts
756756
}
757-
o.maxCallAttempts = n
757+
o.maxRetryAttempts = n
758758
})
759759
}
760760

resolver_wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (ccr *ccResolverWrapper) NewAddress(addrs []resolver.Address) {
171171
// ParseServiceConfig is called by resolver implementations to parse a JSON
172172
// representation of the service config.
173173
func (ccr *ccResolverWrapper) ParseServiceConfig(scJSON string) *serviceconfig.ParseResult {
174-
return parseServiceConfig(scJSON, ccr.cc.dopts.maxCallAttempts)
174+
return parseServiceConfig(scJSON, ccr.cc.dopts.maxRetryAttempts)
175175
}
176176

177177
// addChannelzTraceEvent adds a channelz trace event containing the new

service_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ type jsonSC struct {
165165

166166
func init() {
167167
internal.ParseServiceConfig = func(js string) *serviceconfig.ParseResult {
168-
return parseServiceConfig(js, defaultMaxCallAttempts)
168+
return parseServiceConfig(js, defaultMaxRetryAttempts)
169169
}
170170
}
171171
func parseServiceConfig(js string, maxAttempts int) *serviceconfig.ParseResult {

service_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func runParseTests(t *testing.T, testCases []parseTestCase) {
6060
t.Helper()
6161
for i, c := range testCases {
6262
t.Run(fmt.Sprint(i), func(t *testing.T) {
63-
scpr := parseServiceConfig(c.scjs, defaultMaxCallAttempts)
63+
scpr := parseServiceConfig(c.scjs, defaultMaxRetryAttempts)
6464
var sc *ServiceConfig
6565
sc, _ = scpr.Config.(*ServiceConfig)
6666
if !c.wantErr {

0 commit comments

Comments
 (0)