I've created an NSQ producer in my Go microservice and I'm trying to create a method for it to attempt to reconnect after an NSQ restart.
I've looked into the nsq config documentation hoping to see if I could provide a failover method on restart/quit but I haven't had much luck. I'll post how I'm creating my NSQ producer:
type ProducerNSQ struct {
p *nsq.Producer
}
func initConnectionNSQ() (*ProducerNSQ, error) {
config := nsq.NewConfig()
config.UserAgent = common.DeployedService()
config.BackoffMultiplier = time.Duration(time.Second * 10)
producer, err := nsq.NewProducer(dataConfig.NsqAddress, config)
if err != nil {
return nil, err
}
if err := producer.Ping(); err != nil {
return nil, err
}
return &ProducerNSQ{p: producer}, nil
}
All help is much appreciated!