|
|
@ -23,6 +23,13 @@ type ConnectionManager struct { |
|
|
reconnectionCount uint |
|
|
reconnectionCount uint |
|
|
reconnectionCountMu *sync.Mutex |
|
|
reconnectionCountMu *sync.Mutex |
|
|
dispatcher *dispatcher.Dispatcher |
|
|
dispatcher *dispatcher.Dispatcher |
|
|
|
|
|
|
|
|
|
|
|
// universalNotifyBlockingReceiver receives block signal from underlying
|
|
|
|
|
|
// connection which are broadcasted to all publisherNotifyBlockingReceivers
|
|
|
|
|
|
universalNotifyBlockingReceiver chan amqp.Blocking |
|
|
|
|
|
universalNotifyBlockingReceiverUsed bool |
|
|
|
|
|
publisherNotifyBlockingReceiversMu *sync.RWMutex |
|
|
|
|
|
publisherNotifyBlockingReceivers []chan amqp.Blocking |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type Resolver interface { |
|
|
type Resolver interface { |
|
|
@ -62,17 +69,20 @@ func NewConnectionManager(resolver Resolver, conf amqp.Config, log logger.Logger |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
connManager := ConnectionManager{ |
|
|
connManager := ConnectionManager{ |
|
|
logger: log, |
|
|
|
|
|
resolver: resolver, |
|
|
|
|
|
connection: conn, |
|
|
|
|
|
amqpConfig: conf, |
|
|
|
|
|
connectionMu: &sync.RWMutex{}, |
|
|
|
|
|
ReconnectInterval: reconnectInterval, |
|
|
|
|
|
reconnectionCount: 0, |
|
|
|
|
|
reconnectionCountMu: &sync.Mutex{}, |
|
|
|
|
|
dispatcher: dispatcher.NewDispatcher(), |
|
|
|
|
|
|
|
|
logger: log, |
|
|
|
|
|
resolver: resolver, |
|
|
|
|
|
connection: conn, |
|
|
|
|
|
amqpConfig: conf, |
|
|
|
|
|
connectionMu: &sync.RWMutex{}, |
|
|
|
|
|
ReconnectInterval: reconnectInterval, |
|
|
|
|
|
reconnectionCount: 0, |
|
|
|
|
|
reconnectionCountMu: &sync.Mutex{}, |
|
|
|
|
|
dispatcher: dispatcher.NewDispatcher(), |
|
|
|
|
|
universalNotifyBlockingReceiver: make(chan amqp.Blocking), |
|
|
|
|
|
publisherNotifyBlockingReceiversMu: &sync.RWMutex{}, |
|
|
} |
|
|
} |
|
|
go connManager.startNotifyClose() |
|
|
go connManager.startNotifyClose() |
|
|
|
|
|
go connManager.readUniversalBlockReceiver() |
|
|
return &connManager, nil |
|
|
return &connManager, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|