diff --git a/pubsub/transport/amqp/connection.go b/pubsub/transport/amqp/connection.go index 414d01a..697069e 100644 --- a/pubsub/transport/amqp/connection.go +++ b/pubsub/transport/amqp/connection.go @@ -74,6 +74,15 @@ type Connection struct { chReconnectionDelay time.Duration } +func NewReconnectConnection(logger log.Logger, underlyingConn UnderlyingConnection, chReconnectionDelay time.Duration) *Connection { + + return &Connection{ + logger: logger, + underlyingConn: underlyingConn, + chReconnectionDelay: chReconnectionDelay, + } +} + func (c *Connection) Close() error { return c.underlyingConn.Close() } diff --git a/pubsub/transport/amqp/connection_test.go b/pubsub/transport/amqp/connection_test.go index 020a5c0..e3c50b5 100644 --- a/pubsub/transport/amqp/connection_test.go +++ b/pubsub/transport/amqp/connection_test.go @@ -228,3 +228,15 @@ func TestConnection_Channel(t *testing.T) { // testLogger.AssertContainsSubstr(t, "channel recreation succeed") //}) } + +func TestReconnectConnection(t *testing.T) { + t.Run("basic constructor", func(t *testing.T) { + testLogger := log.NewNilLogger() + uc := &MockUnderlyingConnection{} + rc := NewReconnectConnection(testLogger, uc, time.Second) + + assert.Equal(t, rc.underlyingConn, uc) + assert.Equal(t, rc.chReconnectionDelay, time.Second) + assert.NotEmpty(t, rc.logger) + }) +}