mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-19 13:44:53 +01:00
Clean up reconnection loop function
This commit is contained in:
@@ -102,11 +102,7 @@ func (c *defaultAMQPCLient) connect() error {
|
|||||||
func (c *defaultAMQPCLient) reconnectionLoop() error {
|
func (c *defaultAMQPCLient) reconnectionLoop() error {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case amqpError, ok := <-c.notifyCloseChan:
|
case amqpError := <-c.notifyCloseChan:
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
c.logger.Error(amqpError)
|
c.logger.Error(amqpError)
|
||||||
|
|
||||||
expontentialBackoff := backoff.NewExponentialBackOff()
|
expontentialBackoff := backoff.NewExponentialBackOff()
|
||||||
@@ -116,20 +112,11 @@ func (c *defaultAMQPCLient) reconnectionLoop() error {
|
|||||||
|
|
||||||
c.reconFlag.Store(true)
|
c.reconFlag.Store(true)
|
||||||
|
|
||||||
err := backoff.Retry(func() error {
|
c.logger.Info("amqp: trying to reconnect...")
|
||||||
c.logger.Info("amqp: trying to reconnect...")
|
err := backoff.Retry(c.connect, expontentialBackoff)
|
||||||
|
|
||||||
err := c.connect()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
c.logger.Info("amqp: succesfully reconnected")
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}, expontentialBackoff)
|
|
||||||
|
|
||||||
c.reconFlag.Store(false)
|
c.reconFlag.Store(false)
|
||||||
|
c.logger.Info("amqp: succesfully reconnected")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, listener := range c.listeners {
|
for _, listener := range c.listeners {
|
||||||
|
|||||||
Reference in New Issue
Block a user