houseofcat / turbocookedrabbit

A user friendly RabbitMQ library written in Golang.
MIT License
107 stars 20 forks source link

error:IndividualConsumerLoop can not loop out anyway #42

Closed jonny-mark closed 2 years ago

jonny-mark commented 2 years ago
func (rs *RabbitService) collectConsumerErrors() {
MonitorLoop:
    for {
        for _, consumer := range rs.consumers {
        IndividualConsumerLoop:
            for {
                if rs.shutdown {
                    break MonitorLoop // Prevent leaking goroutine
                }

                select {
                case err := <-consumer.Errors():
                    rs.centralErr <- err
                default:
                    break IndividualConsumerLoop
                }
            }
        }

        time.Sleep(rs.monitorSleepInterval)
    }
}

------it could be like this-----

func (rs *RabbitService) collectConsumerErrors() {

MonitorLoop:
    for {
    IndividualConsumerLoop:
        for _, consumer := range rs.consumers {
            for {
                if rs.shutdown {
                    break MonitorLoop // Prevent leaking goroutine
                }

                select {
                case err := <-consumer.Errors():
                    rs.centralErr <- err
                default:
                    break IndividualConsumerLoop
                }
            }
        }

        time.Sleep(rs.monitorSleepInterval)
    }
}