I try to write my simple eventemitter wrapper for amqplib/callback_api. I have trouble with handling sitaution when rabbit is not available or disconnected.
I have method getConnect
which returns Promise, which resolves when connection established. But if connection is refused Promise obviously rejects. How to force this method do reconnection while connection will not wstablished
/**
* Async method getConnect for connection
* @returns {Promise<*>}
*/
getConnect = async () => {
return new Promise((resolve, reject) => {
amqp.connect(this.config.url, async function(err, conn) {
if (err) {
reject(err);
}
resolve(conn);
})
})
};
Whole code is here https://github.com/kimonniez/rabbitEE
Maybe, I'm already very sleepy, but I'm completely confused :) Thanks in advance!