Skip to content
Open
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
6 changes: 6 additions & 0 deletions runtime/tchannel_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ type TChannelClientOption struct {

// MaxAttempts is the maximum retry count for a client
MaxAttempts int

// RetryOn is the types of errors to retry on.
RetryOn tchannel.RetryOn
}

// TChannelClient implements TChannelCaller and makes outgoing Thrift calls.
Expand All @@ -98,6 +101,7 @@ type TChannelClient struct {
headerPatterns []string
altChannelMap map[string]*tchannel.SubChannel
maxAttempts int
retryOn tchannel.RetryOn
}

// NewTChannelClient is deprecated, use NewTChannelClientContext instead
Expand Down Expand Up @@ -143,6 +147,7 @@ func NewTChannelClientContext(
headerPatterns: opt.HeaderPatterns,
altChannelMap: opt.AltChannelMap,
maxAttempts: opt.MaxAttempts,
retryOn: opt.RetryOn,
}
return client
}
Expand Down Expand Up @@ -205,6 +210,7 @@ func (c *TChannelClient) call(
retryOpts := tchannel.RetryOptions{
TimeoutPerAttempt: c.timeoutPerAttempt,
MaxAttempts: c.maxAttempts,
RetryOn: c.retryOn,
}

//override timeout and retry config with endpoint level’s config
Expand Down
16 changes: 16 additions & 0 deletions runtime/tchannel_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,19 @@ func TestMaxAttemptFieldWithNoSet(t *testing.T) {
maxAttempts := contextBuilder.RetryOptions.MaxAttempts
assert.Equal(t, maxAttempts, 0)
}

func TestRetryOnDefault(t *testing.T) {
methodName := map[string]string{
"methodKey": "methodValue",
}
tChannelClient := &TChannelClient{
serviceName: "test",
methodNames: methodName,
timeout: 1,
}
ctx := context.TODO()
retryOpts := tchannel.RetryOptions{}
contextBuilder := tchannel.NewContextBuilder(tChannelClient.timeout).SetParentContext(ctx).SetRetryOptions(&retryOpts)
retryOn := contextBuilder.RetryOptions.RetryOn
assert.Equal(t, retryOn, tchannel.RetryDefault)
}