config: add Dialer field to ConnectionConfig and PoolConfig with option constructors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package transport
|
||||
|
||||
import (
|
||||
"git.wisehodl.dev/jay/go-honeybee/types"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
@@ -21,6 +22,7 @@ type ConnectionConfig struct {
|
||||
IncomingBufferSize int
|
||||
ErrorsBufferSize int
|
||||
Retry RetryConfig
|
||||
Dialer types.Dialer
|
||||
}
|
||||
|
||||
type RetryConfig struct {
|
||||
@@ -220,6 +222,13 @@ func WithErrorsBufferSize(value int) ConnectionOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithConnectionDialer(d types.Dialer) ConnectionOption {
|
||||
return func(c *ConnectionConfig) error {
|
||||
c.Dialer = d
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func WithRetryDisabled() ConnectionOption {
|
||||
return func(c *ConnectionConfig) error {
|
||||
c.Retry.Disabled = true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package transport
|
||||
|
||||
import (
|
||||
"git.wisehodl.dev/jay/go-honeybee/honeybeetest"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"net/http"
|
||||
"testing"
|
||||
@@ -253,3 +254,10 @@ func TestValidateConnectionConfig(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithConnectionDialer(t *testing.T) {
|
||||
mock := &honeybeetest.MockDialer{}
|
||||
conf, err := NewConnectionConfig(WithConnectionDialer(mock))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, mock, conf.Dialer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user