Skip to content

Commit 2690bff

Browse files
committed
fix reviews
1 parent e8f20d4 commit 2690bff

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

internal/topic/retriable_error.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import (
1313
)
1414

1515
const (
16-
DefaultStartTimeout = time.Minute
16+
DefaultStartTimeout = time.Minute
17+
connectionEstablishedTimeout = time.Minute
1718
)
1819

1920
type RetrySettings struct {
@@ -46,7 +47,7 @@ var (
4647
func CheckResetReconnectionCounters(lastTry, now time.Time, connectionTimeout time.Duration) bool {
4748
const resetAttemptEmpiricalCoefficient = 10
4849
if connectionTimeout == value.InfiniteDuration {
49-
return false
50+
return now.Sub(lastTry) > connectionEstablishedTimeout
5051
}
5152
return now.Sub(lastTry) > connectionTimeout*resetAttemptEmpiricalCoefficient
5253
}

internal/topic/retriable_error_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,17 @@ func TestCheckResetReconnectionCounters(t *testing.T) {
243243
shouldReset bool
244244
}{
245245
{
246-
name: "InfiniteConnectionTimeout",
247-
lastTry: time.Time{},
246+
name: "RecentLastTryWithInfiniteConnectionTimeout",
247+
lastTry: now.Add(-30 * time.Second),
248248
connectionTimeout: value.InfiniteDuration,
249249
shouldReset: false,
250250
},
251+
{
252+
name: "OldLastTryWithInfiniteConnectionTimeout",
253+
lastTry: now.Add(-30 * time.Minute),
254+
connectionTimeout: value.InfiniteDuration,
255+
shouldReset: true,
256+
},
251257
{
252258
name: "LastTryLessThanConnectionTimeout",
253259
lastTry: now.Add(-30 * time.Second),

0 commit comments

Comments
 (0)