Created public api, cleaned up internals.
This commit is contained in:
+2
-8
@@ -147,15 +147,9 @@ func WithWriteTimeout(value time.Duration) ConnectionOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithRetry enables retry with default parameters (infinite retries,
|
||||
// 1s initial delay, 5s max delay, 0.5 jitter factor).
|
||||
//
|
||||
// If passed after granular retry options (WithRetryMaxRetries, etc.),
|
||||
// it will overwrite them. Use either WithRetry alone or the granular
|
||||
// options; not both.
|
||||
func WithRetry() ConnectionOption {
|
||||
func WithoutRetry() ConnectionOption {
|
||||
return func(c *ConnectionConfig) error {
|
||||
c.Retry = GetDefaultRetryConfig()
|
||||
c.Retry = nil
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,13 +107,12 @@ func TestWithWriteTimeout(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWithRetry(t *testing.T) {
|
||||
t.Run("default", func(t *testing.T) {
|
||||
conf := &ConnectionConfig{}
|
||||
opt := WithRetry()
|
||||
t.Run("without retry", func(t *testing.T) {
|
||||
conf := GetDefaultConnectionConfig()
|
||||
opt := WithoutRetry()
|
||||
err := applyConnectionOptions(conf, opt)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, conf.Retry)
|
||||
assert.Equal(t, conf.Retry, GetDefaultRetryConfig())
|
||||
assert.Nil(t, conf.Retry)
|
||||
})
|
||||
|
||||
t.Run("with attempts", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user