diff --git a/pool.go b/pool.go index 92c378e..621d0b7 100644 --- a/pool.go +++ b/pool.go @@ -62,7 +62,7 @@ type pool struct { errors chan error done chan struct{} - config *ConnectionConfig + config *PoolConfig logger *slog.Logger mu sync.RWMutex @@ -131,12 +131,12 @@ type OutboundPool struct { dialer Dialer } -func NewOutboundPool(config *ConnectionConfig, logger *slog.Logger) (*OutboundPool, error) { +func NewOutboundPool(config *PoolConfig, logger *slog.Logger) (*OutboundPool, error) { if config == nil { - config = GetDefaultConnectionConfig() + config = GetDefaultPoolConfig() } - if err := validateConnectionConfig(config); err != nil { + if err := validatePoolConfig(config); err != nil { return nil, err } @@ -200,7 +200,7 @@ func (p *OutboundPool) Connect(url string) error { if p.logger != nil { logger = p.logger.With("url", url) } - conn, err := NewConnection(url, p.config, logger) + conn, err := NewConnection(url, p.config.ConnectionConfig, logger) if err != nil { return err } diff --git a/pool_test.go b/pool_test.go index 0a06d5a..b050077 100644 --- a/pool_test.go +++ b/pool_test.go @@ -68,13 +68,15 @@ func TestPoolConnect(t *testing.T) { }) t.Run("fails to add connection", func(t *testing.T) { - pool, err := NewOutboundPool(&ConnectionConfig{ - Retry: &RetryConfig{ - MaxRetries: 1, - InitialDelay: 1 * time.Millisecond, - MaxDelay: 5 * time.Millisecond, - }, - }, nil) + pool, err := NewOutboundPool( + &PoolConfig{ + ConnectionConfig: &ConnectionConfig{ + Retry: &RetryConfig{ + MaxRetries: 1, + InitialDelay: 1 * time.Millisecond, + MaxDelay: 5 * time.Millisecond, + }}, + }, nil) assert.NoError(t, err) pool.dialer = &MockDialer{ DialFunc: func(string, http.Header) (Socket, *http.Response, error) {